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}."
msgstr ""
msgctxt "#30709"
msgid "Geo-blocked video"
msgstr ""
msgctxt "#30710"
msgid "This video is geo-blocked and can't be played from your location."
msgstr ""
msgctxt "#30711"
msgid "Unavailable video"
msgstr ""
msgctxt "#30712"
msgid "The video is unavailable and can't be played right now."
msgstr ""

View File

@ -137,18 +137,10 @@ msgctxt "#30702"
msgid "An error occurred while authenticating: {error}."
msgstr "Er is een fout opgetreden tijdens het aanmelden: {error}."
msgctxt "#30709"
msgid "Geo-blocked video"
msgstr "Video is geografisch geblokkeerd"
msgctxt "#30710"
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."
msgctxt "#30711"
msgid "Unavailable video"
msgstr "Onbeschikbare video"
msgctxt "#30712"
msgid "The video is unavailable and can't be played right now."
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)
@routing.route('/play/catalog')
@routing.route('/play/catalog/<uuid>')
def play_catalog(uuid):
def play_catalog(uuid=None):
""" Play the requested item """
from resources.lib.modules.player import Player
Player().play(uuid)

View File

@ -36,6 +36,13 @@ class Player:
""" Play the live channel.
: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))
kodiutils.ok_dialog(message=kodiutils.localize(30718, channel=channel_name.get('name'))) # There is no live stream available for {channel}.
kodiutils.end_of_directory()
@ -44,6 +51,10 @@ class Player:
""" Play the requested item.
:type path: string
"""
if not path:
kodiutils.ok_dialog(message=kodiutils.localize(30712)) # The video is unavailable...
return
# Get episode information
episode = self._api.get_episode(path, cache=CACHE_PREVENT)
resolved_stream = None
@ -88,6 +99,10 @@ class Player:
""" Play the requested item.
:type uuid: string
"""
if not uuid:
kodiutils.ok_dialog(message=kodiutils.localize(30712)) # The video is unavailable...
return
# Lookup the stream
resolved_stream = self._resolve_stream(uuid)
if resolved_stream.license_url:
@ -130,11 +145,11 @@ class Player:
return None
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
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
@staticmethod

View File

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