Don't play old episodes trough the TV guide

This commit is contained in:
Michaël Arnauts 2020-03-21 20:34:30 +01:00
parent c44dbcd4d3
commit 860d91fc51

View File

@ -96,6 +96,14 @@ class EpgApi:
else: else:
airing = False 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( return EpgProgram(
channel=channel, channel=channel,
program_title=data.get('program_title'), program_title=data.get('program_title'),
@ -111,8 +119,8 @@ class EpgApi:
description=data.get('content_episode'), description=data.get('content_episode'),
duration=duration, duration=duration,
program_url=(data.get('program_node', {}).get('url') or '').lstrip('/'), program_url=(data.get('program_node', {}).get('url') or '').lstrip('/'),
video_url=(data.get('video_node', {}).get('url') or '').lstrip('/'), video_url=video_url,
cover=data.get('video_node', {}).get('image'), cover=cover,
airing=airing, airing=airing,
) )
@ -142,6 +150,7 @@ class EpgApi:
""" """
response = self._session.get(url) response = self._session.get(url)
# TODO check error code if response.status_code != 200:
raise Exception('Could not fetch data')
return response.text return response.text