Skip to content

Commit

Permalink
[PL - TVABC] Add lives
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-ernest authored and joaopa00 committed Oct 1, 2023
1 parent 498c5ac commit 3cef368
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
52 changes: 52 additions & 0 deletions resources/lib/channels/pl/tvabc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# GNU General Public License v2.0+ (see LICENSE.txt or https://www.gnu.org/licenses/gpl-2.0.txt)

# This file is part of Catch-up TV & More

import json
import urlquick

from codequick import Resolver

from resources.lib import web_utils


URL_API = 'https://krainaabc.tvp.pl/sess/TVPlayer2/api.php'

GENERIC_HEADERS = {'User-Agent': web_utils.get_random_ua()}


@Resolver.register
def get_live_url(plugin, item_id, **kwargs):
channel_code = {
'tvpabc': '442',
'tvpabc2': '4O1',
}
channel_identity = {
'tvabc': '51696812',
'tvabc2': '57181933'
}

params = {
'@method': 'getTvpConfig',
'@callback': '__anthill_jsonp_%s__' % channel_code[item_id],
'corsHost': 'krainaabc.tvp.pl',
'id': channel_identity[item_id]
}

resp = urlquick.get(URL_API, params=params, headers=GENERIC_HEADERS, max_age=-1, timeout=30)

# extract json content from jsonp reply
resp_json_body = resp.text.split("(", 1)[1]
resp_json_body = resp_json_body[:1 + resp_json_body.rfind("}")]
# parse json
resp_json = json.loads(resp_json_body)

video_files = resp_json.get('content').get('files')
for video_file in video_files:
if 'hls' == video_file.get('type'):
return video_file.get('url')
default_url = video_files[0].get('url')
if default_url is not None:
return default_url

return False
17 changes: 17 additions & 0 deletions resources/lib/skeletons/pl_live.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,21 @@
'enabled': True,
'order': 9
},
'tvpabc': {
'resolver': '/resources/lib/channels/pl/tvpabc:get_live_url',
'label': 'TVP ABC',
'thumb': 'channels/pl/tvpabc.png',
'fanart': 'channels/pl/tvpabc_fanart.jpg',
'enabled': True,
'order': 10
},
'tvpabc2': {
'resolver': '/resources/lib/channels/pl/tvpabc:get_live_url',
'label': 'TVP ABC 2',
'thumb': 'channels/pl/tvpabc2.png',
'fanart': 'channels/pl/tvpabc_fanart.jpg',
'enabled': True,
'order': 8
'order': 11

Check failure on line 112 in resources/lib/skeletons/pl_live.py

View workflow job for this annotation

GitHub Actions / Flake8

resources/lib/skeletons/pl_live.py#L112

SyntaxError: invalid syntax (E999)
},
}

0 comments on commit 3cef368

Please sign in to comment.