Improve playback error handling (#87)

This commit is contained in:
Michaël Arnauts 2021-04-23 23:27:55 +02:00 committed by GitHub
parent d5551f4e9e
commit 0edbad10df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 22 deletions

View File

@ -136,18 +136,10 @@ msgctxt "#30702"
msgid "An error occurred while authenticating: {error}." msgid "An error occurred while authenticating: {error}."
msgstr "" msgstr ""
msgctxt "#30709"
msgid "Geo-blocked video"
msgstr ""
msgctxt "#30710" msgctxt "#30710"
msgid "This video is geo-blocked and can't be played from your location." msgid "This video is geo-blocked and can't be played from your location."
msgstr "" msgstr ""
msgctxt "#30711"
msgid "Unavailable video"
msgstr ""
msgctxt "#30712" msgctxt "#30712"
msgid "The video is unavailable and can't be played right now." msgid "The video is unavailable and can't be played right now."
msgstr "" msgstr ""

View File

@ -137,18 +137,10 @@ msgctxt "#30702"
msgid "An error occurred while authenticating: {error}." msgid "An error occurred while authenticating: {error}."
msgstr "Er is een fout opgetreden tijdens het aanmelden: {error}." msgstr "Er is een fout opgetreden tijdens het aanmelden: {error}."
msgctxt "#30709"
msgid "Geo-blocked video"
msgstr "Video is geografisch geblokkeerd"
msgctxt "#30710" msgctxt "#30710"
msgid "This video is geo-blocked and can't be played from your location." msgid "This video is geo-blocked and can't be played from your location."
msgstr "Deze video is geografisch geblokkeerd en kan niet worden afgespeeld vanaf je locatie." msgstr "Deze video is geografisch geblokkeerd en kan niet worden afgespeeld vanaf je locatie."
msgctxt "#30711"
msgid "Unavailable video"
msgstr "Onbeschikbare video"
msgctxt "#30712" msgctxt "#30712"
msgid "The video is unavailable and can't be played right now." msgid "The video is unavailable and can't be played right now."
msgstr "Deze video is niet beschikbaar en kan nu niet worden afgespeeld." msgstr "Deze video is niet beschikbaar en kan nu niet worden afgespeeld."

View File

@ -159,8 +159,9 @@ def play_epg(channel, timestamp):
TvGuide().play_epg_datetime(channel, timestamp) TvGuide().play_epg_datetime(channel, timestamp)
@routing.route('/play/catalog')
@routing.route('/play/catalog/<uuid>') @routing.route('/play/catalog/<uuid>')
def play_catalog(uuid): def play_catalog(uuid=None):
""" Play the requested item """ """ Play the requested item """
from resources.lib.modules.player import Player from resources.lib.modules.player import Player
Player().play(uuid) Player().play(uuid)

View File

@ -36,6 +36,13 @@ class Player:
""" Play the live channel. """ Play the live channel.
:type channel: string :type channel: string
""" """
# TODO: this doesn't work correctly, playing a live program from the PVR won't play something from the beginning
# Lookup current program
# broadcast = self._epg.get_broadcast(channel, datetime.datetime.now().isoformat())
# if broadcast and broadcast.video_url:
# self.play_from_page(broadcast.video_url)
# return
channel_name = CHANNELS.get(channel, dict(name=channel)) channel_name = CHANNELS.get(channel, dict(name=channel))
kodiutils.ok_dialog(message=kodiutils.localize(30718, channel=channel_name.get('name'))) # There is no live stream available for {channel}. kodiutils.ok_dialog(message=kodiutils.localize(30718, channel=channel_name.get('name'))) # There is no live stream available for {channel}.
kodiutils.end_of_directory() kodiutils.end_of_directory()
@ -44,6 +51,10 @@ class Player:
""" Play the requested item. """ Play the requested item.
:type path: string :type path: string
""" """
if not path:
kodiutils.ok_dialog(message=kodiutils.localize(30712)) # The video is unavailable...
return
# Get episode information # Get episode information
episode = self._api.get_episode(path, cache=CACHE_PREVENT) episode = self._api.get_episode(path, cache=CACHE_PREVENT)
resolved_stream = None resolved_stream = None
@ -88,6 +99,10 @@ class Player:
""" Play the requested item. """ Play the requested item.
:type uuid: string :type uuid: string
""" """
if not uuid:
kodiutils.ok_dialog(message=kodiutils.localize(30712)) # The video is unavailable...
return
# Lookup the stream # Lookup the stream
resolved_stream = self._resolve_stream(uuid) resolved_stream = self._resolve_stream(uuid)
if resolved_stream.license_url: if resolved_stream.license_url:
@ -130,11 +145,11 @@ class Player:
return None return None
except GeoblockedException: except GeoblockedException:
kodiutils.ok_dialog(heading=kodiutils.localize(30709), message=kodiutils.localize(30710)) # This video is geo-blocked... kodiutils.ok_dialog(message=kodiutils.localize(30710)) # This video is geo-blocked...
return None return None
except UnavailableException: except UnavailableException:
kodiutils.ok_dialog(heading=kodiutils.localize(30711), message=kodiutils.localize(30712)) # The video is unavailable... kodiutils.ok_dialog(message=kodiutils.localize(30712)) # The video is unavailable...
return None return None
@staticmethod @staticmethod

View File

@ -36,8 +36,8 @@ class TvGuide:
dates = [] dates = []
today = datetime.today() today = datetime.today()
# The API provides 7 days in the past and 13 days in the future # The API provides 7 days in the past and 8 days in the future
for i in range(-7, 13): for i in range(-7, 8):
day = today + timedelta(days=i) day = today + timedelta(days=i)
if i == -1: if i == -1:
@ -131,7 +131,7 @@ class TvGuide:
if program.video_url: if program.video_url:
path = kodiutils.url_for('play_from_page', channel=channel, page=quote(program.video_url, safe='')) path = kodiutils.url_for('play_from_page', channel=channel, page=quote(program.video_url, safe=''))
else: else:
path = None path = kodiutils.url_for('play_catalog', uuid='')
title = '[COLOR gray]' + title + '[/COLOR]' title = '[COLOR gray]' + title + '[/COLOR]'
stream_dict = STREAM_DICT.copy() stream_dict = STREAM_DICT.copy()