ok I’m quite aware that this isn’t what Picard was made for, but I’ve found that picard is a better option than trying to do this via AtomicParsley or any of the other great, but essentially difficult, mp4 metadata processors out there. Not sure, but I’m sure I don’t want to know, what library it uses, but the GUI option is amazing and the scripting makes it flexible for my uses.
I’m writing a script that will embed metadata from Kodi nfo file into a video file. Almost everything is done except images.Most of what i’ve got done i’ve done from analyzing the picard’s own code (documentation is lacking, no offense meant) but as far as setting images from files, I can’t figure it out.
here’s the code I have so far (i’ve added ‘pass’ in place of extremely long or irrelevant code)
PLUGIN_NAME = u’Get Tags from Kodi Metadata’
PLUGIN_AUTHOR = u’Nobahdi Atoll’
PLUGIN_DESCRIPTION = u’‘‘Gets Video Tags from Kodi NFO’’’
PLUGIN_VERSION = ‘0.1’
PLUGIN_API_VERSIONS = [‘0.15’]from picard.file import File
from picard.ui.itemviews import BaseAction, register_file_actionimport re
import osclass ApplyKodiMetadata(BaseAction):
NAME = ‘Apply Kodi Metadata’def callback(self, objs): for video in objs: if isinstance(video, File): fileInfo = self.getFileInfo(video) # get fileinfo for easier processing self.processFilename(fileInfo['basenamebase']) #initially get metadata from known regex patterns self.processNFO(fileInfo['basenamebase'] + '.nfo') #process NFO info if found self.findThumbnail(fileInfo['basenamebase'] + '-thumb') def getFileInfo(self, video): infoReturn = dict() infoReturn['fullpath'] = video.filename # full path to file infoReturn['path'] = os.path.dirname(video.filename) # dir file exists in infoReturn['basename'] = os.path.basename(video.filename) # the filename alone infoReturn['basenamebase'] = os.path.splitext(infoReturn['basename'])[0] # the filename alone no extension infoReturn['basepath'] = os.path.join(infoReturn['path'], infoReturn['basenamebase']) return infoReturn def processFileName(self, basefilename): pass def processNFO(self,nfoPath): if os.path.exists(nfoPath) and os.path.isfile(nfoPath): #check nfo path exists and is a file pass def findThumbnail(self,basethumbnailPath): if os.path.exists(basethumbnailPath + '.jpg'): #how do i tell it to load this file as the ONLY image in the metadata?
register_file_action(ApplyKodiMetadata())
So this is where I’m at… can anyone help?.