From 860d91fc512fafe1418be67378ba890f11df1b36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Arnauts?= Date: Sat, 21 Mar 2020 20:34:30 +0100 Subject: [PATCH] Don't play old episodes trough the TV guide --- resources/lib/viervijfzes/epg.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/resources/lib/viervijfzes/epg.py b/resources/lib/viervijfzes/epg.py index 6cf5b79..06e7cb6 100644 --- a/resources/lib/viervijfzes/epg.py +++ b/resources/lib/viervijfzes/epg.py @@ -96,6 +96,14 @@ class EpgApi: else: airing = False + # Only allow direct playing if the linked video is the actual program + if data.get('video_node', {}).get('latest_video'): + video_url = (data.get('video_node', {}).get('url') or '').lstrip('/') + cover = data.get('video_node', {}).get('image') + else: + video_url = None + cover = None + return EpgProgram( channel=channel, program_title=data.get('program_title'), @@ -111,8 +119,8 @@ class EpgApi: description=data.get('content_episode'), duration=duration, program_url=(data.get('program_node', {}).get('url') or '').lstrip('/'), - video_url=(data.get('video_node', {}).get('url') or '').lstrip('/'), - cover=data.get('video_node', {}).get('image'), + video_url=video_url, + cover=cover, airing=airing, ) @@ -142,6 +150,7 @@ class EpgApi: """ response = self._session.get(url) - # TODO check error code + if response.status_code != 200: + raise Exception('Could not fetch data') return response.text