Hi,
I'm writing a plugin for DocumentaryAddicts.com.
The plugin works fine, however at present I have to use a seperate page to parse the youtube url for a video item, which means you have to click inside an object and then click again to play. This is not ideal, I would prefer for the video to launch as it is. I presume this is possible, but I don't know how to do it.
def VideoList(page):
oc = ObjectContainer()
html = HTML.ElementFromURL(ROOT_PATH % page)
Log(html)
nextPage = ""
prevPage = ""
for row in html.xpath("//div[@class=\'pagination\']/a"):
if (row.text.strip()=="Next Page"):
nextPage = row.get("href")
if (row.text.strip()=="Previous Page"):
prevPage = row.get("href")
if (len(prevPage)!=0):
oc.add(DirectoryObject(key = Callback(VideoList, page = prevPage), title = "[Previous Page]"))
for row in html.xpath('//div[@class=\'large-3 small-12 columns vidbrowse\']'):
url = row.xpath("./div/a[1]")[0].get("href")
title = row.xpath("./div/a[1]")[0].get("title")
thumb = row.xpath("./div/a[1]/img")[0].get("src")
description = row.xpath("./p[2]")[0].text
views = row.xpath("./p[3]")[0].text
category = row.xpath("./p[1]")[0].text
oc.add(DirectoryObject(key = Callback(VideoPage, url=url), title=title, summary=description, thumb=Resource.ContentsOfURLWithFallback(thumb)))
if (len(nextPage)!=0):
oc.add(DirectoryObject(key = Callback(VideoList, page = nextPage), title = "[Next Page]"))
return oc
def VideoPage(url):
oc = ObjectContainer()
html = HTML.ElementFromURL(ROOT_PATH%url)
data = html.xpath("//div[@id=‘video’]/iframe")[0].get(“src”)
video_id = re.match(“http://www.youtube.com/embed/([^?]+)?", data).group(1)
url = “http://www.youtube.com/watch?v=%s”%video_id
title = html.xpath(”//div[@class=‘large-12 small-12 columns’]/h2/span")[0].text
description = html.xpath("//div[@class=‘text-justify’]")[0].text
rating = html.xpath("//div/strong/span/span")[0].text
oc.add(VideoClipObject(url=url, summary=description, title=title, rating=float(rating)))
return oc
I've tried a few things, such as using VideoClipObject instead of DirectoryObject using the VideoPage function as a callback, but I couldn't get this to work.