Hello,
I have an existing movie library, and for each movie i have the TMDB id. Is it possible to invoke tmdb3 script directly for each folder and pass TMDB ID for metadata lookup?
At the moment I have to goto 'Media Library' invoke a scan and feed TMDB id manually for each file. Unfortunately, my movie file name as the quality as well like so
ABC (2011)/ABC (2011) Bluray-1080p.mkv
MythTV does not automatically parse the format correctly and hence i need paste the TMDB ID manually.
Thanks
Invoke tmdb3 via a script and pass tmdb id
Re: Invoke tmdb3 via a script and pass tmdb id
Not 100% sure what your filenames are, but I've been doing some similar things, so here's what I've found. Maybe it will be helpful.trumee wrote: ↑Sun Feb 02, 2020 1:30 pmHello,
I have an existing movie library, and for each movie i have the TMDB id. Is it possible to invoke tmdb3 script directly for each folder and pass TMDB ID for metadata lookup?
At the moment I have to goto 'Media Library' invoke a scan and feed TMDB id manually for each file. Unfortunately, my movie file name as the quality as well like so
ABC (2011)/ABC (2011) Bluray-1080p.mkv
MythTV does not automatically parse the format correctly and hence i need paste the TMDB ID manually.
Thanks
I'm using the Videos service for a lot of this.
https://www.mythtv.org/wiki/Video_Service
AddVideo - This will add a video by filename. It can parse some metadata from the filename as discussed here:
https://www.mythtv.org/wiki/MythVideo_File_Parsing
It won't search for an inetref as far as I can tell. Hasn't on any video I've added. But it's populated title, season, episode, and subtitle for series episodes I've added.
I found AddVideo does not work if you haven't set up a storage group for videos.
viewtopic.php?f=36&t=3557
AddVideo does not return the id of the newly-added video. For that, I call GetVideoByFileName with the same filename used in AddVideo.
Then, with the id, you can call UpdateVideoMetadata to update one or more fields. I've tried adding just the inetref. That works, but you still have to go into the frontend, highlight the video, and press W to start a metadata lookup job. As far as I can tell, this can't be automated. mythutil --scanvideos probably would for everything, but I haven't tried that recently.
As far as your filenames, if you want to use a format mythtv can't parse for title etc. you can use the above to UpdateVideoMetadata with the correct title. However, inetref may be enough, and even if you change the title first, running a metadata lookup job may update it again based on what data it finds for the inetref. That happens when I add a video for "The Office" and ttvdb.py finds "The Office (US)" from the inetref.
BTW inetref seems to be the script name (different for tv and movies) plus "_" plus the id, and mythtv parses that apart before running the script with parameters. Watch the log or processes if you need to see exactly how the script is called.
Re: Invoke tmdb3 via a script and pass tmdb id
Thanks, I was able to successfully add a video and its inetref. However, the metadata does not update when using mythutl --scanvideos. The only way to pull metadata is to open a frontend and scan for new videos (use 'M' key). This means that the whole workflow cannot be automated.
Re: Invoke tmdb3 via a script and pass tmdb id
Interesting. Before I started using the services, I had only been running mythutil --scanvideos. I found that for isos with a filename such as "Disc 1.iso" that they were being looked up and found a title of "Disco" with description, actors, etc. in French. I found that's actually a French movie.
So it seems that mythutil --scanvideos does try to look up metadata from the filename, but I haven't looked at the code yet to see exactly how it works. Maybe it doesn't use inetref? Or maybe the syntax you inserted for inetref was wrong? Maybe try running the script manually and see what info it finds, if any?
But yeah, I'm a little bummed you can't automate the same metadata lookup that happens when you press "W". Since I'm transcoding recordings, I'll be taking as much as I can from the recorded/recordedprogram tables and calling UpdateVideoMetadata with it. But for videos not recorded OTA, obviously you can't do that.
I suppose you could write your own script to call the tmdb or ttvdb script with the correct id, parse the results, and call UpdateVideoMetadata with it.
So it seems that mythutil --scanvideos does try to look up metadata from the filename, but I haven't looked at the code yet to see exactly how it works. Maybe it doesn't use inetref? Or maybe the syntax you inserted for inetref was wrong? Maybe try running the script manually and see what info it finds, if any?
But yeah, I'm a little bummed you can't automate the same metadata lookup that happens when you press "W". Since I'm transcoding recordings, I'll be taking as much as I can from the recorded/recordedprogram tables and calling UpdateVideoMetadata with it. But for videos not recorded OTA, obviously you can't do that.
I suppose you could write your own script to call the tmdb or ttvdb script with the correct id, parse the results, and call UpdateVideoMetadata with it.
Re: Invoke tmdb3 via a script and pass tmdb id
I found another function called LookupVideo. It is supposed to lookup the video. It looks up the video, however it does not populate the database automatically. Looks like that has to done via a script too.
Re: Invoke tmdb3 via a script and pass tmdb id
That's the intent of LookupVideo. You get the results and use them as needed (not
necessarily updating metadata.) Here's a (very basic) example. No error checking
and all hardcoded.:
Ref: https://www.mythtv.org/wiki/Python_API_Examples
necessarily updating metadata.) Here's a (very basic) example. No error checking
and all hardcoded.:
Code: Select all
#!/usr/bin/python2
''' Basic GET/POST example '''
from __future__ import print_function
import json
from MythTV.services_api import send as api
BACKEND = api.Send(host='BackendHostNameOrIP')
REST = 'FileName=The Perfect Storm.vob'
VIDEO = BACKEND.send(endpoint='Video/GetVideoByFileName', rest=REST)
# Info only, print the entire response:
#print(json.dumps(VIDEO, indent=4, sort_keys=True, separators=(',', ': ')))
VIDEO = VIDEO['VideoMetadataInfo']
REST = '{}&Inetref=2133'.format(VIDEO['Title'])
METADATA = BACKEND.send(endpoint='Video/LookupVideo', rest=REST)
#print(json.dumps(METADATA, indent=4, sort_keys=True, separators=(',', ': ')))
#print(METADATA['VideoLookupList']['Count'])
METADATA = METADATA['VideoLookupList']['VideoLookups'][0]
POSTDATA = dict()
POSTDATA['Id'] = VIDEO['Id']
POSTDATA['Title'] = METADATA['Title']
# fill in others are desired ...
POSTDATA['Year'] = METADATA['Year']
BACKEND.send(endpoint='Video/UpdateVideoMetadata', postdata=POSTDATA,
opts={'wrmi': True})
Re: Invoke tmdb3 via a script and pass tmdb id
@wmorrison you should find that UpdataVideoMetadata does work, however,
the Details aren't updated until you leave the Watch Videos page and re-enter
it. I don't have a solution for that.
the Details aren't updated until you leave the Watch Videos page and re-enter
it. I don't have a solution for that.
Re: Invoke tmdb3 via a script and pass tmdb id
Right, I understand the purpose of the function. However, I dont want to re-implement what mythfrontend provides already does. I have populated the Inetref using a script and would like MythTv to pull the metadata. The 'W' key provides that functionality. I am wondering how can i invoke that using a script?