So I’m writing a channel for my favorite Anime streaming website.
Currently I just wanna get a paginated list from their REST API which works, I get a list of 50 entries and I’m creating TVShowObjects for every Anime and after going through the loop I create a NextPageObject which also works fine. The only thing that is messed up are the titles when I get to the second or third page and I can’t find a way to fix this issue, here is my code:
@handler(PREFIX, TITLE, art=ART, thumb=ICON)
def MainMenu():
oc = ObjectContainer()
oc.add(DirectoryObject(key=Callback(ShowEntryList, title=L("Anime"), medium="animeseries"), title=L("Anime")))
return oc
@route(PREFIX + '/showentrylist', page=int)
def ShowEntryList(title, medium = 'animeseries', page = 0):
oc = ObjectContainer(title2 = title)
url = # the url
values = { 'api_key' : WebsiteAPIKey, 'kat' : 'anime', 'medium' : medium, 'limit' : '50', 'p' : page }
animes = JSON.ObjectFromURL(url, values)
for anime in animes['data']:
# unimportant stuff
oc.add(TVShowObject(
# unimportant stuff
))
oc.add(NextPageObject(
key = Callback(ShowEntryList, title = L("Page ") + str(page + 2), medium = medium, page = page + 1),
title = L("Next Page")
))
return oc
So when I select my channel, the title above shows Channel Name which is what I want, then I select the entry Anime and the title shows Channel Name and Anime, just like I defined it, no problem. But now I select the Next Page entry at the bottom and now it says Anime and Page 2, which is exactly what I want, but when I select Next Page again, it shows Page 2 and Page 3 in the title which is not what I want, how can I fix this?
It seems like every time I select a new page, the ObjectContainer changes title2 to title1 and then it’s all messed up…