Skip to content

Commit

Permalink
Display a specific message, when TVP server doesn't allow playing cha…
Browse files Browse the repository at this point in the history
…nnel
  • Loading branch information
thomas-ernest committed Sep 29, 2023
1 parent 56f9c33 commit 7d81a99
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions resources/lib/channels/pl/tvp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'):
Expand All @@ -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
2 changes: 1 addition & 1 deletion resources/lib/channels/pl/tvpabc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 7d81a99

Please sign in to comment.