From 4761108db590a9c7d12db7a6df3cb7c83756ffeb Mon Sep 17 00:00:00 2001 From: mediaminister <45148099+mediaminister@users.noreply.github.com> Date: Fri, 4 Oct 2024 10:34:21 +0200 Subject: [PATCH] Fix getting latest episode (#1192) --- resources/lib/api.py | 4 ++-- tests/test_routing.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/resources/lib/api.py b/resources/lib/api.py index cc9ae6c4..6f15746e 100644 --- a/resources/lib/api.py +++ b/resources/lib/api.py @@ -432,7 +432,7 @@ def get_latest_episode_data(program_name): variables = { 'pageId': '/vrtnu/a-z/{}.model.json'.format(program_name), } - return api_req(graphql_query, operation_name, variables) + return api_req(graphql_query, operation_name, variables, client='MobileAndroid') def get_seasons_data(program_name): @@ -1050,7 +1050,7 @@ def get_latest_episode(program_name): page = api_data.get('data').get('page') if page: most_relevant_ep = page.get('components')[0].get('mostRelevantEpisodeTile') - if most_relevant_ep.get('title') == 'Meest recente aflevering': + if most_relevant_ep and most_relevant_ep.get('title') == 'Meest recente aflevering': latest_episode = most_relevant_ep else: items = page.get('components')[1].get('items')[0].get('components')[0] diff --git a/tests/test_routing.py b/tests/test_routing.py index 03be6834..10ae080f 100644 --- a/tests/test_routing.py +++ b/tests/test_routing.py @@ -233,8 +233,8 @@ def test_play_livestream_by_id_route(self): @unittest.skipUnless(xbmc_addon.settings.get('password'), 'Skipping as VRT password is missing.') def test_play_latestepisode_route(self): """Play last episode method: /play/lastepisode/""" - addon.run(['plugin://plugin.video.vrt.nu/play/latest/het-journaal', '0', '']) - self.assertEqual(plugin.url_for(addon.play_latest, program_name='het-journaal'), 'plugin://plugin.video.vrt.nu/play/latest/het-journaal') + addon.run(['plugin://plugin.video.vrt.nu/play/latest/vrt-nws-journaal', '0', '']) + self.assertEqual(plugin.url_for(addon.play_latest, program_name='vrt-nws-journaal'), 'plugin://plugin.video.vrt.nu/play/latest/vrt-nws-journaal') addon.run(['plugin://plugin.video.vrt.nu/play/latest/terzake', '0', '']) self.assertEqual(plugin.url_for(addon.play_latest, program_name='terzake'), 'plugin://plugin.video.vrt.nu/play/latest/terzake') addon.run(['plugin://plugin.video.vrt.nu/play/latest/winteruur', '0', ''])