From 0edbad10df0955fc86ca425bd9134dcdaaa8cb19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Arnauts?= Date: Fri, 23 Apr 2021 23:27:55 +0200 Subject: [PATCH] Improve playback error handling (#87) --- .../resource.language.en_gb/strings.po | 8 -------- .../resource.language.nl_nl/strings.po | 8 -------- resources/lib/addon.py | 3 ++- resources/lib/modules/player.py | 19 +++++++++++++++++-- resources/lib/modules/tvguide.py | 6 +++--- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/resources/language/resource.language.en_gb/strings.po b/resources/language/resource.language.en_gb/strings.po index f9f9a06..aedd6d9 100644 --- a/resources/language/resource.language.en_gb/strings.po +++ b/resources/language/resource.language.en_gb/strings.po @@ -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 "" diff --git a/resources/language/resource.language.nl_nl/strings.po b/resources/language/resource.language.nl_nl/strings.po index c86ff09..833e3d2 100644 --- a/resources/language/resource.language.nl_nl/strings.po +++ b/resources/language/resource.language.nl_nl/strings.po @@ -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." diff --git a/resources/lib/addon.py b/resources/lib/addon.py index c2f6490..4410a1d 100644 --- a/resources/lib/addon.py +++ b/resources/lib/addon.py @@ -159,8 +159,9 @@ def play_epg(channel, timestamp): TvGuide().play_epg_datetime(channel, timestamp) +@routing.route('/play/catalog') @routing.route('/play/catalog/') -def play_catalog(uuid): +def play_catalog(uuid=None): """ Play the requested item """ from resources.lib.modules.player import Player Player().play(uuid) diff --git a/resources/lib/modules/player.py b/resources/lib/modules/player.py index fab7f84..c993f26 100644 --- a/resources/lib/modules/player.py +++ b/resources/lib/modules/player.py @@ -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 diff --git a/resources/lib/modules/tvguide.py b/resources/lib/modules/tvguide.py index 13ef1c6..6bbc6fb 100644 --- a/resources/lib/modules/tvguide.py +++ b/resources/lib/modules/tvguide.py @@ -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()