I’m creating a toy plugin at the moment to get my feet wet with Plex development. So I’m working from the forum walkthrough and just trying to get a simple set of hierarchical menus going. (At the moment it’s filled with various images of cats, the “hello world” of internet scraping tools. )
I’m not able to get any thumbnails to show up for my directory items, though. I’ve tried just putting the URL in straight and I’ve also tried copying the method of the Apple Trailers channel to wrap the image in a DataObject. Either of those techniques works just fine for setting the art, but if I pass the same parameter to “thumb” I don’t see anything on the screen or any errors in the log.
My code is below; I’m sure there’s something obvious I’m doing wrong, but I can’t see what it might be.
<br />
<br />
PREFIX = "/applications/TEST"<br />
NAME = "TEST Plugin"<br />
ART = 'art-default.jpg'<br />
ICON = 'icon-default.png'<br />
<br />
def Start():<br />
Plugin.AddPrefixHandler(PREFIX, MainMenu, NAME, ICON, ART)<br />
Plugin.AddViewGroup("List", viewMode = "List", mediaType = "items")<br />
<br />
MediaContainer.art = R(ART)<br />
MediaContainer.title1 = NAME<br />
MediaContainer.viewGroup = "List"<br />
DirectoryItem.thumb = R(ICON)<br />
<br />
def MainMenu():<br />
dir = MediaContainer(viewMode = "List")<br />
dir.Append(Function(DirectoryItem(LiveMenu, "Live")))<br />
return dir<br />
<br />
def LiveMenu(sender):<br />
oc = ObjectContainer(view_group = "List")<br />
<br />
oc.add(<br />
DirectoryObject(<br />
key=Callback(ChannelMenu, channel=1), <br />
title="Channel 1", <br />
art="http://lexfridman.com/blogs/thoughts/files/2012/06/fat-cat.jpg",<br />
thumb="http://www.cs.brown.edu/orgs/artemis/2012/catsoftheworld/lime-cat.jpg"<br />
# art=Callback(<br />
# GetImage, <br />
# url="http://www.helpinghomelesscats.com/images/cat1.jpg"<br />
# ),<br />
# thumb=Callback(<br />
# GetImage,<br />
# url="http://www.cs.brown.edu/orgs/artemis/2012/catsoftheworld/lime-cat.jpg"<br />
# )<br />
)<br />
)<br />
<br />
return oc<br />
<br />
def ChannelMenu(sender, channel = None):<br />
pass<br />
<br />
def GetImage(url):<br />
Log("Getting image: " + url)<br />
try:<br />
data = HTTP.Request(url, cacheTime=CACHE_1MONTH).content<br />
return DataObject(data, 'image/jpeg')<br />
except:<br />
pass<br />
<br />
return Redirect(R(ICON))<br />