Need help - why does my function not work - thumbnail related
Basically it's to add a video link to a list:

def AddListItem (Name, Url, Image):
        if (Image == ""):
                Image = "DefaultVideo.png"
                Image = str (os.path.join (os.getcwd (), 'images', Image))
        guiListItem = xbmcgui.ListItem (Name, Image, Image)
        guiListItem.setInfo (type = "Video", infoLabels = {"Title": Name})
        success = xbmcplugin.addDirectoryItem (int (sys.argv[1]), Url, guiListItem)
        return success

If the Image parameter is null then it displays the DefaultVideo.png image fine. But the parameter actually has an image filename input then it displays nothing.

I have checked and the image does exist in the folder: %plugin_dir%\images\. Have tried another image too just to make sure it isn't the image.

Also made sure I imported os & os.path.

What am I doing wrong? Syntax error? (This is my first hour of python Smile)

your number of parms to ListItem is incorrect, missing a label2 before giving the image.

ListItem([label, label2, iconImage, thumbnailImage])

listitem = xbmcgui.ListItem('Casino Royale', '[PG-13]', 'blank-poster.tbn', 'poster.tbn')

so your example should be:

guiListItem = xbmcgui.ListItem (Name, "", Image, Image)

Python will let you reference parms by name should you wish to exclude some:
guiListItem = xbmcgui.ListItem (Name, iconImage=Image, thumbnailImage=Image)

You might also want to assign a var to your images location then your func doesn't have to build it each time.
DIR_HOME = os.getcwd ()
DIR_IMAGES = os.path.join (DIR_HOME , 'images' )

then in func:
imgPath = os.path.join (DIR_IMAGES, Image)

Retired from Add-on dev
Knew it was something stupid.

Thanks! - Working now.

EDIT: Now it doesn't show the "DefaultVideo.png" for some reason
Thread Rating:
  • 1 Vote(s) - 5 Average

Logout Mark Read Team Forum Stats Members Help
Need help - why does my function not work - thumbnail related51