How does "art" and/or "thumb" come into the channels main menu XML?

Browsing a channel, eg. 127.0.0.1:32400/video/abc, the PMS delivered XML looks like that...


  
...

Looking over the channels source code (__init__.py) the main gets specified here (as far as I understand):

def Start():
    ObjectContainer.title1 = NAME
[...]

While the directory entries are added further down:

def MainMenu():
[...]
    oc.add(DirectoryObject(
        key = Callback(Season, title=title, show_id=show_id.group(1)),
        title = title,
        summary = summary
    ))
[...]

Now, I really have to wonder, where PMS grabs the data/URL for the "art" and "thumb" attributes from... Any ideas?


Now, I really have to wonder, where PMS grabs the data/URL for the "art" and "thumb" attributes from... Any ideas?

By looking @ the code, since I sadly is in the wrong region, and haven't got a supported player, I would say it's in the episodes:

@route('/video/abc/episodes')
def Episodes(title, show_id, season):
oc = ObjectContainer(title2=title)
html = GetHTML(EPISODES % (show_id, season))

for episode in html.xpath('//div[contains(@class, "reg_tile")]'):
	url = episode.xpath('./div[@class="tile_title"]/a/@href')[0]
	if not url.startswith('http://'):
		url = BASE_URL + url

	if not '/VDKA' in url:
		continue

	if '/watch/this-week/' in url:
		url = url.replace('abc.go.com', 'abcnews.go.com')

	title = episode.xpath('./div[@class="tile_title"]/a/text()')[0]
	summary = episode.xpath('./div[@class="tile_desc"]/text()')[0]
	thumb = episode.xpath('./div[@class="thumb"]/a/img/@src')[0]

	try:
		air_date = episode.xpath('./div[@class="show_tile_sub"]/text()')[0]
		date = RE_AIR_DATE.search(air_date).groupdict()
		air_date = '%s-%s-20%s' % (date['month'], date['day'], date['year'])
		originally_available_at = Datetime.ParseDate(air_date).date()
	except:
		originally_available_at = None

	oc.add(VideoClipObject(
		url = url,
		title = title,
		summary = summary,
		thumb = Resource.ContentsOfURLWithFallback(url=thumb)
	))

return oc

/Tommy

For the episodes, I am fine. They come with an own thumbnail, each of them.

The initial directory however comes back with the shown XML, where the URL points to sort of a default "ABC" thumbnail.

Try it here: http://resources-cdn.plexapp.com/image/source/com.plexapp.plugins.abc.jpg?h=32d5cb5

I see what you mean now.....Had to download ABC plugin, and fiddle a tad with supported browsers etc. though....

So I got challenged here, and not sure, but guessing here......

If a plug-in doesn't come with it's own resources, then they'll be downloaded from Plex, meaning they kinda have to be the official plug-ins.

Take a peek in the ...../Plug-ins/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/components/runtime.py file for this:

class HostedResource(object):
  def __init__(self, core, rtype, group, identifier, ext):
    self._core = core
    self._rtype = rtype
    self._group = group
    self._identifier = identifier
    self._ext = ext

def str(self):
filename = self._core.runtime.filename_for_hosted_resource(self._rtype, self._identifier, self._ext)
file_hash = str(self._core.runtime.hash_for_hosted_resource(self._rtype, self._group, self._identifier, self._ext))
url = “http://resources-cdn.plexapp.com/%s/%s/%s?h=%s” % (self._rtype, self._group, filename, file_hash)
return url

/Tommy

Example plugins that you may be looking at most likely have their default art and thumb images stored in the plexinc/resources folder on Github. Plugins that are listed in the Channel Store have had their default images moved to the plexinc/resources folder on Github. Since, unless or until a plugin is accepted into the Channel Store, you will instead have the art and thumb images for your plugin stored locally in the Resources folder of your plugin bundle, you will need to include code in your __init__.py to define them and set them as the default.

Usually, you will assign them a global variable at the top of your __init__.py and then in the Start() menu you can list the default values for the title,  art and thumb attributes for the different types of objects you will be using in your code. Then, if you do not include a value for the thumb or art attribute for any of those types of objects later in your code, it will use the default value you assigned in the Start() menu.

The Webisodes channel plugin shows an example of a Start() menu where the art and thumb are assigned a default value for all the different types of objects that are used in the code - https://github.com/shopgirl284/Webisodes.bundle/blob/master/Contents/Code/__init__.py#L27. It is accessing the art and thumb images that was saved in the Resources folder of the plugin bundle under the names art-default.jpg and icon-default.png here - https://github.com/shopgirl284/Webisodes.bundle/tree/master/Contents/Resources.

For example, under your global variables, you assign a variable called ICON for your default thumb image that you had named icon-default.png

ICON = 'icon-default.png'

Then in the Start() menu, you would give a default value of any DirectoryObject()'s thumb attribute of the global variable ICON located in your Resources folder (the R() designates its location is in the Resources folder):

DirectoryObject.thumb = R(ICON)

Then if you added a DirectoryObject anywhere in your code and only include a title attribute, but did not include a thumb attribute, like this:

oc.add(DirectoryObject(key=Callback(VideoPage, title=title, url=url), title = title))

it will use the icon-default.png located in the Resources folder of this plugin that you specified above for the value of the thumb for any DirectoryObject() that does not specify a thumb.

Usually, you do not need to assign a default value for the thumbs in your VideoClipObjects() or EpisodeObjects(), since you will usually parse and give a value for the thumb attribute for these objects.

Hey, thanks!

Great walk-through... I will give it a try! :-D

Question... Is the 

DirectoryObject.thumb = R(ICON)

the same as in

Plugin.AddPrefixHandler("/video/queue", MainMenu, NAME, 'icon-default.png', 'art-default.png')

? Or do I need to set up that DirectoryObject nonetheless?

Edit: The AddPrefixHandler() thing seems to be outdated (?). It got removed from my working version a long time ago. Too bad, that I always forget where my sources are stored. :-)

The way to do that now is to use @handler and as far as I know you don't actually need to set the default icon and art (but you do need to include them if you're making a new channel as then by default the channel grabs the hosted resources for the channel).

@handler('/video/golfchannel', NAME)

http://dev.plexapp.com/docs/api/runtimekit.html?highlight=handler#handler

Well, my stupid plugin code didn't deliver the art or thumb attributes to PMS - which in turn didn't add those into the channel's top level XML. The result was, that I only saw a bunch of grey boxes (running on aTV/PlexConnect).

I am not quite sure where/how the defaults for the @handler( ) decorator would come into play...

What I know for a fact, though, with the code proposed by shopgirl284 life is good (say: more colorful) again! :-D

You can only leave out the thumb and art parameter if the thumb and art are located on the hosted resources CDN. Otherwise you have to specify the thumb and art like this:

@handler('/video/yourchannel', NAME, thumb='icon-default.jpg', art='art-default.jpg')

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.