diff --git a/channels/channel.se/svt/chn_svt.py b/channels/channel.se/svt/chn_svt.py index 9a54b286..aa7d0747 100644 --- a/channels/channel.se/svt/chn_svt.py +++ b/channels/channel.se/svt/chn_svt.py @@ -2,6 +2,8 @@ # SPDX-License-Identifier: GPL-3.0-or-later import datetime +from typing import Optional + import pytz from resources.lib import chn_class, mediatype, contenttype @@ -88,10 +90,13 @@ def __init__(self, channel_info): parser=["data", "selectionById", "items"], creator=self.create_api_typed_item) - self._add_data_parser("https://api.svt.se/contento/graphql?operationName=FionaPage", - name="GraphQL FionaPage parsers for Nytt pa Play", json=True, - parser=["data", "selectionById", "items"], - creator=self.create_api_typed_item) + self._add_data_parsers([ + "https://api.svt.se/contento/graphql?operationName=FionaPage", + "https://contento.svt.se/graphql?operationName=FionaPage" + ], + name="GraphQL FionaPage parsers for Nytt pa Play", json=True, + parser=["data", "selectionById", "items"], + creator=self.create_api_typed_item) self._add_data_parser("https://api.svt.se/contento/graphql?operationName=MainGenres", name="GraphQL for main genre listding", json=True, @@ -220,8 +225,8 @@ def add_live_items_and_genres(self, data): LanguageHelper.get_localized_string(LanguageHelper.NewOnChannel) % self.channelName: ( self.__get_api_url( "FionaPage", - "dc8f85e195903fe6227a76ec1e1d300d470ee8ea123bea6bee26215cc6e4959d", - variables={"includeFullOppetArkiv": True, "selectionId": "svtId_egWQ3y7"}), + "b4e65a8f4cedc6bd9981e3539690908443f625c6854ea65f18c4b3b3be66b5dc", + variables={"includeFullOppetArkiv": True, "selectionId": "svtId_82dDX2v"}), False) } # https://api.svt.se/contento/graphql?operationName=FionaPage&variables={"includeFullOppetArkiv":true,"selectionId":"svtId_egWQ3y7","userIsAbroad":true}&extensions={"persistedQuery":{"sha256Hash":"dc8f85e195903fe6227a76ec1e1d300d470ee8ea123bea6bee26215cc6e4959d","version":1}}&ua=svtplaywebb-render-low-prio-client @@ -645,7 +650,7 @@ def create_api_episode_type(self, result_set, add_parent_title=False): item.thumb = self.__get_thumb(result_set["image"], width=720) self.__extract_artwork(result_set.get("images"), item) - valid_from = result_set.get("validFrom", None) + valid_from: Optional[str] = result_set.get("validFrom", None) if bool(valid_from) and valid_from.endswith("Z"): # We need to change the timezone valid_from_date = DateHelper.get_datetime_from_string(valid_from[:-1], time_zone="UTC") @@ -658,7 +663,7 @@ def create_api_episode_type(self, result_set, add_parent_title=False): valid_from_date = DateHelper.get_date_from_string(valid_from, "%Y-%m-%dT%H:%M:%S") item.set_date(*valid_from_date[0:6]) - valid_to = result_set.get("validTo", None) + valid_to: Optional[str] = result_set.get("validTo", None) if valid_to: self.__set_expire_time(valid_to, item) diff --git a/tests/channel_tests/test_chn_nos2010.py b/tests/channel_tests/test_chn_nos2010.py index 674ee535..3e5ac497 100644 --- a/tests/channel_tests/test_chn_nos2010.py +++ b/tests/channel_tests/test_chn_nos2010.py @@ -51,7 +51,7 @@ def test_recent_sub_items(self): self.assertGreater(len(items), 10) def test_series_without_season(self): - items = self._test_folder_url("https://npo.nl/start/api/domain/programs-by-season?guid=9d87c512-bf2d-4df9-8e33-e0792615ed50", 3) + items = self._test_folder_url("https://npo.nl/start/api/domain/programs-by-season?guid=9d87c512-bf2d-4df9-8e33-e0792615ed50", 1) self.assertTrue(all([i.is_playable for i in items])) def test_series_with_seasons_via_slug(self): diff --git a/tests/channel_tests/test_chn_svt.py b/tests/channel_tests/test_chn_svt.py index 40b57daa..a76c0900 100644 --- a/tests/channel_tests/test_chn_svt.py +++ b/tests/channel_tests/test_chn_svt.py @@ -45,7 +45,8 @@ def test_genre_recent_news(self): self._test_folder_url(url, expected_results=4) def test_new_on_svt(self): - url = "https://api.svt.se/contento/graphql?operationName=FionaPage&variables=%7B%22includeFullOppetArkiv%22%3Atrue%2C%22selectionId%22%3A%22svtId_egWQ3y7%22%2C%22userIsAbroad%22%3Atrue%7D&extensions=%7B%22persistedQuery%22%3A%7B%22sha256Hash%22%3A%22dc8f85e195903fe6227a76ec1e1d300d470ee8ea123bea6bee26215cc6e4959d%22%2C%22version%22%3A1%7D%7D&ua=svtplaywebb-render-low-prio-client" + # url = "https://contento.svt.se/graphql?operationName=FionaPage&variables=%7B%22includeFullOppetArkiv%22%3Atrue%2C%22selectionId%22%3A%22svtId_82dDX2v%22%2C%22userIsAbroad%22%3Atrue%7D&extensions=%7B%22persistedQuery%22%3A%7B%22sha256Hash%22%3A%22b4e65a8f4cedc6bd9981e3539690908443f625c6854ea65f18c4b3b3be66b5dc%22%2C%22version%22%3A1%7D%7D&ua=svtplaywebb-render-prod-low-prio-client" + url = "https://api.svt.se/contento/graphql?operationName=FionaPage&variables=%7B%22includeFullOppetArkiv%22%3Atrue%2C%22selectionId%22%3A%22svtId_82dDX2v%22%2C%22userIsAbroad%22%3Atrue%7D&extensions=%7B%22persistedQuery%22%3A%7B%22sha256Hash%22%3A%22b4e65a8f4cedc6bd9981e3539690908443f625c6854ea65f18c4b3b3be66b5dc%22%2C%22version%22%3A1%7D%7D&ua=svtplaywebb-render-low-prio-client" self._test_folder_url(url, expected_results=4) def test_latest_news(self): diff --git a/tests/test_listfilter.py b/tests/test_listfilter.py index e05517aa..d3731df5 100644 --- a/tests/test_listfilter.py +++ b/tests/test_listfilter.py @@ -53,6 +53,6 @@ def tearDown(self): def __get_items(self): items = self._test_folder_url( - "https://npo.nl/start/api/domain/programs-by-season?guid=4a1b312d-6a54-4838-ac8c-640ded14fb07", + "https://npo.nl/start/api/domain/programs-by-season?guid=43eb0443-7ac8-4629-a7ed-b39ab65574b5", expected_results=1, retry=0) return items