Hi! At first, sorry... I'm spanish and i don't speak english...
I found an error in NextUp episodes...
Code:
# NextUp episodes
json_result = getJSON('VideoLibrary.GetTVShows', '{ "sort": { "order": "descending", "method": "lastplayed" }, "filter": {"and": [{"operator":"true", "field":"inprogress", "value":""}]}, "properties": [ "title" ] }')
for item in json_result:
json_query2 = getJSON('VideoLibrary.GetEpisodes', '{ "tvshowid": %d, "sort": {"method":"episode"}, "filter": {"and": [ {"field": "playcount", "operator": "lessthan", "value":"1"}, {"field": "season", "operator": "greaterthan", "value": "0"} ]}, "properties": [ %s ], "limits":{"end":1}}' %(item['tvshowid'], fields_episodes))
for item2 in json_query2:
lastplayed = item2["lastplayed"]
if not item2["title"] in allTitles:
allOndeckItems.append((lastplayed,item2))
allTitles.append(item2["title"])
Doesn't work, because the episodes list doesn't have "lastplayed" data (is Null on unwatched episodes), and sorted function can't sort this. I suggest this:
Code:
# NextUp episodes
json_result = getJSON('VideoLibrary.GetTVShows', '{ "sort": { "order": "descending", "method": "lastplayed" }, "filter": {"and": [{"operator":"true", "field":"inprogress", "value":""}]}, "properties": [ "title", "lastplayed" ] }')
for show in json_result:
json_query2 = getJSON('VideoLibrary.GetEpisodes', '{ "tvshowid": %d, "sort": {"method":"episode"}, "filter": {"and": [ {"field": "playcount", "operator": "lessthan", "value":"1"}, {"field": "season", "operator": "greaterthan", "value": "0"} ]}, "properties": [ %s ], "limits":{"end":1}}' %(show['tvshowid'], fields_episodes))
for item in json_query2:
lastplayed = sorted([show["lastplayed"], item["dateadded"]], reverse=True)[0]
if not item["title"] in allTitles:
allOndeckItems.append((lastplayed,item))
allTitles.append(item["title"])
This works, and the new weekly episodes comes to the beginning, at least until you see another episode.
Maybe you can test.
Thanks for this!