From 7d81a99d08bfbd10040692c72cbc19f3f099ad5d Mon Sep 17 00:00:00 2001 From: thomas-ernest Date: Fri, 29 Sep 2023 20:48:33 +0200 Subject: [PATCH] Display a specific message, when TVP server doesn't allow playing channel --- resources/lib/channels/pl/tvp.py | 11 +++++++++-- resources/lib/channels/pl/tvpabc.py | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/resources/lib/channels/pl/tvp.py b/resources/lib/channels/pl/tvp.py index 2fe2a755d..679c5fd53 100644 --- a/resources/lib/channels/pl/tvp.py +++ b/resources/lib/channels/pl/tvp.py @@ -76,7 +76,7 @@ def _get_channels(): Extract the listing of channels from TVP page as a list of JSON elments. None if HTTP request fails or infomation moved to another place in the HTML page. """ - resp = urlquick.get(LIVE_MAIN_URL, headers=GENERIC_HEADERS, max_age=-1) + resp = urlquick.get(LIVE_MAIN_URL, headers=GENERIC_HEADERS, max_age=-1, timeout=30) root = resp.parse() channels_str = None @@ -135,11 +135,15 @@ def _get_live_stream_url(live_id): } url = URL_STREAMS.format(live_id=live_id) try: - live_streams_url = urlquick.get(url, headers=headers, max_age=-1) + live_streams_url = urlquick.get(url, headers=headers, max_age=-1, timeout=30) live_streams = live_streams_url.json() except Exception: return None + live_stream_status = live_streams.get('status', None) + if live_stream_status is not None and live_stream_status != 'OK': + return live_stream_status + live_stream_url = None if live_streams.get('formats', None) is not None: for stream_format in live_streams.get('formats'): @@ -165,5 +169,8 @@ def get_live_url(plugin, item_id, **kwargs): if live_stream_url is None: plugin.notify('INFO', plugin.localize(30716)) return False + if not live_stream_url.startswith('http'): + plugin.notify('INFO', plugin.localize(30891)) + return False return live_stream_url diff --git a/resources/lib/channels/pl/tvpabc.py b/resources/lib/channels/pl/tvpabc.py index ec0157a75..2841d07c0 100644 --- a/resources/lib/channels/pl/tvpabc.py +++ b/resources/lib/channels/pl/tvpabc.py @@ -15,12 +15,12 @@ 'tvpabc2': 'https://krainaabc.tvp.pl/sess/TVPlayer2/api.php?@method=getTvpConfig&@callback=__anthill_jsonp_401__&corsHost=krainaabc.tvp.pl&id=57181933' } + @Resolver.register def get_live_url(plugin, item_id, **kwargs): resp = urlquick.get(URL_LIVE[item_id], headers={'User-Agent': web_utils.get_random_ua()}, max_age=-1, timeout=30) - print('newresp=', resp.text) # extract json content from jsonp reply resp_json_body = resp.text.split("(", 1)[1]