From b454b28554cfdffc742bb08b7214b8dfc82cdc1e Mon Sep 17 00:00:00 2001 From: Bas Rieter Date: Thu, 5 Dec 2024 20:56:32 +0100 Subject: [PATCH] Version: plugin.video.retrospect-5.7.21. --- changelog.txt | 12 ++++-------- channels/channel.nos/nos2010/chn_nos2010.py | 18 +++++++++++++++++- tests/channel_tests/test_chn_nos2010.py | 10 ++++++++++ 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/changelog.txt b/changelog.txt index a9c68739..a31ee1e9 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,16 +1,12 @@ -[B]Retrospect v5.7.21 - Changelog - 2024-11-26[/B] +[B]Retrospect v5.7.xx - Changelog - 2024-xx-xx[/B] -Fixed some minor channel issues for Dutch and Swedish channels. +t.b.d. [B]Framework related[/B] -* Added: Patch option to UriHandler. +_None_ [B]GUI/Settings/Language related[/B] _None_ [B]Channel related[/B] -* Fixed: NPO Plus content not showing (Fixes #1862). -* Fixed: Some TV4 content (with encryption) was not playing (Fixes #1853). -* Fixed: Revoking a device from Videoland.nl broke Retrospect listing (Fixes #1852). -* Fixed: BVN Images did not show (Fixes #1864). -* Fixed: Don't use HVEC for SVT (Fixes #1865). \ No newline at end of file +* Fixed: NPO 'Recent' items broke if there were too many season results (Fixes #1871). diff --git a/channels/channel.nos/nos2010/chn_nos2010.py b/channels/channel.nos/nos2010/chn_nos2010.py index 3af02e76..9daa8a01 100644 --- a/channels/channel.nos/nos2010/chn_nos2010.py +++ b/channels/channel.nos/nos2010/chn_nos2010.py @@ -122,6 +122,12 @@ def __init__(self, channel_info: ChannelInfo): parser=[], creator=self.create_api_season_item, updater=self.update_epg_series_item) + self._add_data_parser( + "https://npo.nl/start/serie/", + name="Direct link to video", json=True, + updater=self.update_nextjs_video + ) + self._add_data_parsers([ "https://npo.nl/start/api/domain/programs-by-season", "https://npo.nl/start/api/domain/programs-by-series"], @@ -777,8 +783,10 @@ def create_api_epg_item(self, result_set: dict) -> Optional[MediaItem]: program_slug = result_set["program"]["slug"] url = f"https://npo.nl/start/video/{program_slug}" elif series_slug and program_guid: - url = f"https://npo.nl/start/api/domain/series-seasons?slug={series_slug}" + program_slug = result_set["program"]["slug"] season_slug = result_set["season"]["slug"] + # url = f"https://npo.nl/start/api/domain/series-seasons?slug={series_slug}" + url = f"https://npo.nl/start/serie/{series_slug}/{season_slug}/{program_slug}" else: return None @@ -846,6 +854,14 @@ def update_epg_series_item(self, item: MediaItem) -> MediaItem: return self.__update_video_item(item, product_id) + def update_nextjs_video(self, item: MediaItem) -> MediaItem: + data = UriHandler.open(item.url) + next_js_data = Regexer.do_regex(r"__NEXT_DATA__[^>]+>(.+?)", data)[0] + next_js_json = JsonHelper(next_js_data) + data = next_js_json.get_value("props", "pageProps", "dehydratedState", "queries", -1, "state", "data") + p = [p for p in data if p["guid"] == item.metaData["program_guid"]][0] + return self.__update_video_item(item, p["productId"]) + # noinspection PyUnusedLocal def search_site(self, url: Optional[str] = None, needle: Optional[str] = None) -> List[MediaItem]: """ Creates a list of items by searching the site. diff --git a/tests/channel_tests/test_chn_nos2010.py b/tests/channel_tests/test_chn_nos2010.py index ea78811e..d38e87f6 100644 --- a/tests/channel_tests/test_chn_nos2010.py +++ b/tests/channel_tests/test_chn_nos2010.py @@ -69,6 +69,16 @@ def test_series_with_seasons_via_slug(self): self.assertGreaterEqual(len(items), 1) self.assertGreaterEqual(len([i for i in items if i.is_playable]), 1) + def test_update_next_js(self): + from resources.lib.mediaitem import MediaItem + url = "https://npo.nl/start/serie/nos-journaal-20-00-uur/seizoen-61/nos-journaal_96627" + item = MediaItem("Video via NextJS", url) + item.metaData["program_guid"] = "7917478b-8750-498f-8ced-dc6548ef2612" + + item = self.channel.process_video_item(item) + self.assertTrue(item.has_streams()) + self.assertTrue(item.complete) + def test_series_recent_episodes_via_guid(self): self._test_folder_url("https://npo.nl/start/api/domain/programs-by-series?seriesGuid=af032e71-3047-4b22-aac9-c2ef9c8bb9a3&limit=20&sort=-firstBroadcastDate", 2)