Skip to content

Commit

Permalink
Fixed: Show recent videos for series.
Browse files Browse the repository at this point in the history
  • Loading branch information
basrieter committed Nov 17, 2023
1 parent f37283e commit 3cda854
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 17 deletions.
2 changes: 1 addition & 1 deletion addon.xml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
</extension>

<extension point="xbmc.addon.metadata">
<reuselanguageinvoker>true</reuselanguageinvoker>
<reuselanguageinvoker>false</reuselanguageinvoker>
<platform>all</platform>
<license>GPL-3.0-or-later</license>
<language>en nl de sv no lt lv fi</language>
Expand Down
42 changes: 26 additions & 16 deletions channels/channel.nos/nos2010/chn_nos2010.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,23 +553,32 @@ def switch_profile(self, data):

# noinspection PyUnusedLocal
def check_for_single_season(self, data: JsonHelper, items: List[MediaItem]) -> List[MediaItem]:
if len(items) == 1:
# Retry with just this url.
self.parentItem.url = items[0].url
return self.process_folder_list(self.parentItem)

# Not the perfect way as we don't know for sure if the seasonkey is the right value
# to sort by.
# def season_index(item: MediaItem):
# return int(item.metaData.get("seasonKey", 0))
#
# items.sort(key=season_index)
# last_season = items.pop()
# season_items = self.process_folder_list(last_season)
# return items + season_items

# If not seasons, or just one, fetch the episodes
if len(items) != 1:
return items

# Not the perfect way as we don't know for sure if the seasonkey is the right value
# to sort by.
# def season_index(item: MediaItem):
# return int(item.metaData.get("seasonKey", 0))
#
# items.sort(key=season_index)
# last_season = items.pop()
# season_items = self.process_folder_list(last_season)
# return items + season_items

# Retry with just this url.
self.parentItem.url = items[0].url
return self.process_folder_list(self.parentItem)
guid = self.parentItem.metaData.get("guid")
if guid:
url = f"https://npo.nl/start/api/domain/programs-by-series?seriesGuid={guid}&limit=20&sort=-firstBroadcastDate"
recent_data = JsonHelper(UriHandler.open(url))
for result_set in recent_data.get_value():
item = self.create_api_episode_item(result_set)
if item:
items.append(item)

return items

def create_api_program_item(self, result_set: dict) -> Optional[MediaItem]:
title = result_set["title"]
Expand All @@ -586,6 +595,7 @@ def create_api_program_item(self, result_set: dict) -> Optional[MediaItem]:
url = f"https://npo.nl/start/api/domain/programs-by-series?seriesGuid={guid}&limit=20&sort=-firstBroadcastDate"

item = FolderItem(title, url, content_type=contenttype.EPISODES)
item.metaData["guid"] = guid
if "images" in result_set and result_set["images"]:
image_data = result_set["images"][0]
item.set_artwork(thumb=image_data["url"], fanart=image_data["url"])
Expand Down

0 comments on commit 3cda854

Please sign in to comment.