Hey all, quick question:
A plugin I am working on requires me to load an individual url for each video to extract a youtube url. This causes a pretty redundant level of menu hierarchy, as the user is presented with a list of videos (currently DirectoryObjects), chooses one and then is presented with an ObjectContainer containing just one VideoClipObject, which they need to press again to open a third page containing the MetadataObject returned by the built in youtube url service before they can finally play the video clip.
Is there anyway to skip the second step? I have experimented with using VideoClipOjbects on the first page and trying to use a Callback() function for the "url" parameter and that didn't work properly. I also tried returning the VideoClipObject directly, rather than an OC containing just one object. This seemed to work ok on Plex/Web but nothing else? Am I missing something obvious here? Is there anyway to abstract the second page load from the user? Ideally I can present the user with a list of VideoClipObjects and selecting one will take them directly to the MetadataObject for the youtube url.
Heres some code. Hope my question makes sense!
@route(PREFIX + "/showcategory") def ShowCategory(title, category, page_count):oc = ObjectContainer(title1 = title) page_data = HTML.ElementFromURL(BASE_URL + category + "/page/" + str(page_count)) for each in page_data.xpath("//div[@id='region-main']//article[contains(@class,'post')]"): url = each.xpath("./a/@href")[0] title = each.xpath(".//img/@alt")[0] thumb = each.xpath(".//img/@src")[0] summary = each.xpath(".//p/text()")[0] date = each.xpath(".//span[@class='hidden-mobile meta']/text()")[1].rsplit(" | ")[1] oc.add(DirectoryObject( key = Callback(GetVideoObject, url = url), title = title, thumb = Resource.ContentsOfURLWithFallback(url = thumb, fallback='icon-cover.png'), summary = summary ) ) oc.add(NextPageObject( key = Callback(ShowCategory, title = title, category = category, page_count = int(page_count) + 1), title = "More...", thumb = R(ICON_NEXT) ) ) return oc@route(PREFIX + “/getvideoobject”)
def GetVideoObject(url):oc = ObjectContainer() page_data = HTML.ElementFromURL(url) iframe = HTML.ElementFromURL(page_data.xpath("//div[@class='article-detail-media']//iframe/@src")[0]) url = iframe.xpath("//link[@rel='canonical']/@href")[0] oc.add(VideoClipObject( url = url )) return oc