Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions channels/channel.nos/nos2010/chn_nos2010.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def __init__(self, channel_info: ChannelInfo):
# If the user was logged in, we need to refresh the token otherwise it will result in 403
self._add_data_parsers([
"https://npo.nl/start/api/domain/page-collection?collectionId=",
"https://npo.nl/start/api/domain/page-collection?type=series&collectionId=",
"https://npo.nl/start/api/domain/page-collection?collectionType=SERIES&collectionId=",
"https://npo.nl/start/api/domain/search-collection-items?searchType=series"],
name="Collections with series", json=True,
requires_logon=bool(self.__user_name),
Expand All @@ -104,7 +104,7 @@ def __init__(self, channel_info: ChannelInfo):
# If the user was logged in, we need to refresh the token otherwise it will result in 403
self._add_data_parsers([
"https://npo.nl/start/api/domain/search-collection-items?searchType=broadcasts",
"https://npo.nl/start/api/domain/page-collection?type=program&collectionId="
"https://npo.nl/start/api/domain/page-collection?collectionType=PROGRAM&collectionId="
],
name="Collections with videos", json=True,
requires_logon=bool(self.__user_name),
Expand Down Expand Up @@ -151,9 +151,12 @@ def __init__(self, channel_info: ChannelInfo):
name="Bare pages layout", json=True,
parser=["collections"], creator=self.create_api_page_layout)

self._add_data_parser("https://npo.nl/start/api/domain/page-collection?type=dynamic_page&collectionId=",
name="Categories layout", json=True,
parser=["items"], creator=self.create_api_category_item)
self._add_data_parsers([
"https://npo.nl/start/api/domain/page-collection?collectionType=PAGE&collectionId=",
# Not quite sure if dynamic_page still exists, but kept in just in case it does.
"https://npo.nl/start/api/domain/page-collection?collectionType=DYNAMIC_PAGE&collectionId="],
name="Categories layout", json=True,
parser=["items"], creator=self.create_api_category_item)

# Favourites (not yet implemented in the site).
self._add_data_parser("https://npo.nl/start/api/domain/user-profiles",
Expand Down Expand Up @@ -429,7 +432,8 @@ def add_item(language_id: int, url: str, content_type: str,
# content_type=contenttype.TVSHOWS)

add_item(LanguageHelper.TvShows,
"https://npo.nl/start/api/domain/page-layout?layoutId=programmas&layoutType=PAGE",
"https://npo.nl/start/api/domain/page-layout?layoutId=programmas&layoutType=PAGE&includePremiumContent={}&partyId=1".format(
'false' if AddonSettings.hide_premium_items() else 'true'),
content_type=contenttype.TVSHOWS)

live_radio = add_item(
Expand Down Expand Up @@ -653,8 +657,9 @@ def create_api_page_layout(self, result_set: dict) -> Optional[MediaItem]:
else:
guid = result_set["collectionId"]
page_type = result_set["type"]
url = f"https://npo.nl/start/api/domain/page-collection?type={page_type.lower()}&collectionId={guid}&partyId=1&layoutType=PAGE"

include_premium = 'false' if AddonSettings.hide_premium_items() else 'true'
url = (f"https://npo.nl/start/api/domain/page-collection?collectionType={page_type}"
f"&collectionId={guid}&partyId=1&layoutType=PAGE&includePremiumContent={include_premium}")
info = UriHandler.open(url)
info = JsonHelper(info)
title = info.get_value("title")
Expand All @@ -665,7 +670,7 @@ def create_api_page_layout(self, result_set: dict) -> Optional[MediaItem]:
content_type = contenttype.TVSHOWS
elif page_type == "PROGRAM":
content_type = contenttype.EPISODES
elif page_type == "DYNAMIC_PAGE":
elif page_type in ("DYNAMIC_PAGE", "PAGE"):
content_type = contenttype.VIDEOS
else:
Logger.error(f"Missing for page type: {page_type}")
Expand Down
11 changes: 8 additions & 3 deletions tests/channel_tests/test_chn_nos2010.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,19 @@ def test_search_video(self):
self._test_folder_url(url, 5)

def test_programs(self):
self._test_folder_url("https://npo.nl/start/api/domain/page-layout?layoutId=programmas&layoutType=PAGE", 5)
url = "https://npo.nl/start/api/domain/page-layout?layoutId=programmas&layoutType=PAGE&includePremiumContent=true&partyId=1"
self._test_folder_url(url, 5)

@unittest.skip("No longer used")
def test_more_genres(self):
self._test_folder_url("https://npo.nl/start/api/domain/page-collection?type=dynamic_page&collectionId=118e43f3-864a-4dbd-91ea-c6450a8d2c25&partyId=1&layoutType=PAGE", 7)
# TV shows/Genres
url = "https://npo.nl/start/api/domain/page-collection?collectionType=PAGE&collectionId=5817f2c3-dd7f-4c68-9c46-8fe2e630f85f&partyId=1&layoutType=PAGE&includePremiumContent=true"
self._test_folder_url(url, 5)

def test_page(self):
self._test_folder_url("https://npo.nl/start/api/domain/page-collection?type=series&collectionId=db612122-75e0-4f6c-8a32-e9202ae9fce8&partyId=1&layoutType=PAGE", 10)
# TV shows/Nieuws en actualiteiten
url = "https://npo.nl/start/api/domain/page-collection?collectionType=SERIES&collectionId=cab647cf-7bf6-4c7c-9610-cb9e46dbfdde&partyId=1&layoutType=PAGE&includePremiumContent=true"
self._test_folder_url(url, 10)

def test_update_stream_pow(self):
url = "KN_1693383"
Expand Down
Loading