Hi all,
I have a peculiar problem. I'm writing a channel for animetv.org, and in doing so I'm working on the menu hierarchy. I have a top node of an alphabetical list (DirectoryObjects) and below that I have a list of shows. My first try was to use the DirectoryObject here as well and that works just fine, but I wanted some extra fields that the TVShowObject gives, so I changed to that. The only problem is that the thumb and the title/summary always appear twice when using the TVShowObject, whereas when using DirectoryObject everything works as expected. Am I doing something wrong or what?
Example with TVShowObject

Code is
@handler('/video/AnimeTV', 'AnimeTV')
def TopList():
oc = ObjectContainer()
document = HTML.ElementFromURL("http://animetv.org/anime-list/all", cacheTime=3600)
links = document.xpath("//div[@class='letter']/ul/li/a")
for link in links:
oc.add(DirectoryObject(
key=Callback(ShowMenu, url=link.get("href")),
title=link.text,
art="http://i.imgur.com/uCUQI.jpg"
)
)
return oc
def ShowMenu(url):
oc = ObjectContainer()
document = HTML.ElementFromURL(url, cacheTime=3600)
links = document.xpath("//div[@class = ‘vvdo’]")
for link in links:
anchor = link.xpath(“div[@class = ‘vvdo-details’]/h3/a”)[0]
oc.add(ShowMeta(anchor.get(“href”), anchor.text))
return oc
def ShowMeta(url, title):
document = HTML.ElementFromURL(url, cacheTime=3600)
image = document.xpath("//img[@class = ‘anime-pic’]")[0]
episodes = document.xpath("//table[@class = ‘anime-eps’]//a")
Log(title)
return TVShowObject(
key=Callback(EpisodeMenu, url=url),
rating_key=url,
title=title,
summary=image.getnext().text,
thumb=image.get(“src”),
episode_count=len(episodes),
viewed_episode_count=0
)
def EpisodeMenu(url):
oc = ObjectContainer()
document = HTML.ElementFromURL(url, cacheTime=3600)
image = document.xpath("//div[@id = ‘primary-content’]/div/img")[0].get(“src”)
links = document.xpath("//table[@class = ‘anime-eps’]//a")
for link in reversed(links):
episode = HTML.ElementFromURL(link.get(“href”), cacheTime=3600)
playerUrl = episode.xpath("//iframe")[0].get(“src”)
videoNum = playerUrl[playerUrl.find("/watch/")+7:].strip("/")
oc.add(EpisodeObject(
url=link.get(“href”),
title=link.text,
thumb=image,
art=“http://i.imgur.com/uCUQI.jpg”
)
)
return oc