Skip to content

Commit

Permalink
[FR - MYCANAL] new url and APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
darodi committed Jul 29, 2023
1 parent 985f436 commit 2a8dbe8
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions resources/lib/channels/fr/mycanal.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def list_categories(plugin, item_id, **kwargs):
for category in json_react_query_state["queries"][0]["state"]["data"]["strates"]:
if category["type"] == "carrousel":
title = category['context']['context_page_title']
key_value = category['reactKey']
key_value = category['reactKey'] if 'reactKey' in category else None
item = Listitem()
item.label = title
item.set_callback(list_contents, item_id=item_id, key_value=key_value)
Expand All @@ -160,7 +160,7 @@ def list_categories(plugin, item_id, **kwargs):
else:
title = category['context']['context_list_id']
continue
key_value = category['reactKey']
key_value = category['reactKey'] if 'reactKey' in category else None
item = Listitem()
item.label = title
item.set_callback(list_contents, item_id=item_id, key_value=key_value)
Expand All @@ -175,7 +175,7 @@ def list_contents(plugin, item_id, key_value, **kwargs):
json_react_query_state = json.loads(react_query_state)

for category in json_react_query_state["queries"][0]["state"]["data"]["strates"]:
if category['reactKey'] != key_value:
if 'reactKey' in category and category['reactKey'] != key_value:
continue

for content in category["contents"]:
Expand Down Expand Up @@ -441,7 +441,8 @@ def get_video_url(plugin,
'sessionId': sessionId,
}

json_token_parser = session_requests.post(URL_TOKEN, data=payload, headers=headers).json()
resp = session_requests.post(URL_TOKEN, data=payload, headers=headers)
json_token_parser = resp.json()
pass_token = json_token_parser["response"]["passToken"]
device_id = json_token_parser["response"]["userData"]["deviceId"].split(':')[0]

Expand Down Expand Up @@ -475,9 +476,7 @@ def get_video_url(plugin,
return False

for stream_datas in value_datas_jsonparser["available"]:
if stream_datas['drmType'] == "DRM MKPC Widevine DASH" \
or stream_datas['drmType'] == "Non protégé" \
or stream_datas['drmType'] == "UNPROTECTED":
if 'drmType' in stream_datas and is_valid_drm(stream_datas['drmType']):
payload = {
'comMode': stream_datas['comMode'],
'contentId': stream_datas['contentId'],
Expand All @@ -495,6 +494,13 @@ def get_video_url(plugin,
jsonparser_stream_datas = session_requests.put(
URL_STREAM_DATAS, data=payload, headers=secure_gen_hapi_headers).json()

if ('@medias' not in jsonparser_stream_datas
and 'message' in jsonparser_stream_datas
and 'status' in jsonparser_stream_datas
and jsonparser_stream_datas['status'] != 200):
xbmcgui.Dialog().ok('Info', jsonparser_stream_datas['message'])
return False

jsonparser_real_stream_datas = session_requests.get(SECURE_GEN_HAPI +
jsonparser_stream_datas['@medias'],
headers=secure_gen_hapi_headers).json()
Expand Down Expand Up @@ -554,6 +560,14 @@ def get_video_url(plugin,
return json_parser["detail"]["informations"]["playsets"]["available"][0]["videoURL"]


def is_valid_drm(drm_type):
return (drm_type == "DRM MKPC Widevine DASH"
or drm_type == "Non protégé"
or drm_type == "UNPROTECTED"
or drm_type == 'DRM_MKPC_WIDEVINE_DASH'
or drm_type == 'DRM_WIDEVINE')


@Resolver.register
def get_live_url(plugin, item_id, **kwargs):
if xbmcgui.Dialog().select(Script.localize(30174), ["MyCanal", "Dailymotion"]):
Expand Down

0 comments on commit 2a8dbe8

Please sign in to comment.