Talk:Windows MediaBrowser metadata importer for MythTV
A couple suggestions:
- Add 'xml' as an ignored filetype in MythVideo. You may have to rework your script a little, working back from the video names to get the XML files, but IMHO, scanning all those files in just to clear them all out again is ugly. Additionally, with file hashing now in trunk (and to be in 0.23), adding all those extra files on each scan is going to take a long time.
- MythVideo uses the seriesid, season#, and episode# to search for metadata. Putting the episodeid in 'inetref' as this script does will render MythVideo's grabber capacity broken, should you ever wish to use it.
- Use the Python bindings. The Video and MythVideo classes, and ftopen method should be all you need.
The MythVideo class provides database access, as well as a search tool and file scanner.
from MythTV import MythVideo mvid = MythVideo() # find all videos with no listed metadata (inetref=00000000) vids = mvid.searchVideos(custom=(('inetref=%s','00000000'),)) # scan for new content, and missing old content newvids, oldvids = mvid.scanStorageGroup(deleteold=False)
Both commands will return a list of Video objects, which is an abstracted videometadata entry. All objects returned by those commands will at the very least have the filename and host defined. 'ftopen' is a helper method for the FileTransfer class. It will determine whether a file can be accessed locally, and if not will open a file transfer socket to pull it off the backend. The FileTransfer object should behave identically to a standard file object in Python.
from xml.etree.ElementTree import fromstring from MythTV import ftopen vid = vids filename = vid.filename xmlfilename = #whatever you need to work back to the xml file # open a file socket xmlfp = ftopen('myth://Videos@%s/%s' % (vid.host, xmlfilename), 'r') xmlstr = xmlfp.read() xmlfp.close() # read in the xml string and start pulling some data xml = fromstring(xmlstr) vid.director = xml.findtext('Director') vid.plot = xml.findtext('Overview') # push the data onto an existing videometadata record (from searchVideos) vid.update() # or insert a new videometadata record (from scanStorageGroup) vid.create()