Hi All,
I have a few plugins that I've wrote for XBMC, Roku3 and would like to port it to plex for a friend. So far, I've gotten the hang of things, and I have it working. However, I am not satisfied with it, meaning alot can be improved in terms of performance.
1. I have a function that creates the MainMenu, which add the DirectoryObjects with the key=Callback to the function below
2. here is the gut of it
@route(PREFIX + '/collections/{collection_id}/contents', collection_id = int)
def ContentsForCollection(collection_name, collection_id):
requestUrl = BASE_REQUEST_URL + "/collections/%d/contents" %collection_id
oc = ObjectContainer(title1=collection_name)
contents = JSON.ObjectFromURL(requestUrl + "?$include=[Id,Name,Desc,Images,ContentPackages]")
for content in contents['Items']:
try: thumbnail = content['Images'][0]['Url']
except: thumbnail = ''
oc.add(VideoClipObject(
url = requestUrl + "/%d/contentpackages/%d/stacks" %(content['Id'], content['ContentPackages'][0]['Id']),
title=content['Name'],
summary=content['Desc'],
thumb=Resource.ContentsOfURLWithFallback(url=thumbnail, fallback=ICON)
))
if len(oc) < 1:
return ObjectContainer(header="Empty", message="No contents found for " + collection_name)
return oc
and here is the URLService code
def MetadataObjectForURL(url):
Log.Debug(">>>MetadataObjectForURL: " + url)
return VideoClipObject()
def MediaObjectsForURL(url):
Log.Debug(">>>MediaObjectsForURL: " + url)
stacks = JSON.ObjectFromURL(url)
parts = []
for stack in stacks['Items']:
parts.append(PartObject(key=Callback(PlayVideo, url=url + "/%d/manifest.m3u8" %stack['Id'])))
return [
MediaObject(
protocol = 'hls',
parts = parts
)
]
@indirect
def PlayVideo(url):
return IndirectResponse(VideoClipObject, key=HTTPLiveStreamURL(url))
While this work, here are some of the problems I am encountering;
1. From the main menu, if I click a directory and if that directory has over 50+ videos, the plugin crash. and it's due to my noobness --- MediaObjectsForURL makes http calls. this also causes a performance issue, as each item is added to the directory, a call is made to this function. What I want to do is only retrieve it when requested ie, user click on it.
2. MetadataObjectForURL - doesn't seem to get called as I don't see the occurrence of that debug line any where in the log file - by not executing I believe this causes a thrid and final problem
3. Clicking on a video, you'll be presented with a screen and it's very empty, only has a play button.
Now here's the reason why I made an http call in MediaObjectForURL - it's because, the stream to the video is broken up into parts. for example, an 30min show will have 3 part of 10 mins each. I want to play it consecutively. Where would be a good place to grab the parts, would PlayVideo work if so, what can I call to add it?
Any tips on how to improve the performance is greatly appreciated.!
Thanks,
