Scripting Context Menu need help with cover file

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’’’

from picard.file import File
from picard.ui.itemviews import BaseAction, register_file_action

import re
import os

class 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):        

def processNFO(self,nfoPath):
    if os.path.exists(nfoPath) and os.path.isfile(nfoPath): #check nfo path exists and is a file

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?


So this is where I’m at… can anyone help?.

You might be able to set it directly, but I think the cleanest solution would be to implement a cover art provider by subclassing CoverArtProvider. Have a look at the plugin to see an example how a plugin can utilize this.

1 Like

Well the question then becomes can I call a covert art provider plugin from another plugin… I don’t want this interfering with my default settings for Music, so I want this contained within itself, rather than having to chose a cover art provider in settings.

Also it would help if there was actual documentation for plugin development rather than examples, I’ve had to download the code and develop my plugins as if i was actually adding the code into picard in order to use IntelliJ in pyCharm to find out what I can access.