def get_live_url(plugin, item_id, video_id, **kwargs): if get_kodi_version() < 18: xbmcgui.Dialog().ok('Info', plugin.localize(30602)) return False is_helper = inputstreamhelper.Helper('mpd', drm='widevine') if not is_helper.check_inputstream(): return False resp = urlquick.get(URL_LIVE, max_age=-1) live_url = re.compile(r'\'(.*?)mpd').findall(resp.text)[0] + 'mpd' preauthorization_url = re.compile(r'preTokenUrl = \"(.*?)\"').findall( resp.text)[0] resp2 = urlquick.get(preauthorization_url, max_age=-1) json_parser = json.loads(resp2.text) item = Listitem() item.path = live_url item.label = get_selected_item_label() item.art.update(get_selected_item_art()) item.info.update(get_selected_item_info()) item.property['inputstreamaddon'] = 'inputstream.adaptive' item.property['inputstream.adaptive.manifest_type'] = 'mpd' item.property['inputstream.adaptive.license_type'] = 'com.widevine.alpha' item.property[ 'inputstream.adaptive.license_key'] = URL_LICENCE_KEY % json_parser[ "preAuthToken"] return item
def get_live_url(plugin, item_id, live_url, is_drm, live_id, **kwargs): if is_drm: if get_kodi_version() < 18: xbmcgui.Dialog().ok('Info', plugin.localize(30602)) return False is_helper = inputstreamhelper.Helper('mpd', drm='widevine') if not is_helper.check_inputstream(): return False token_url = URL_TOKEN % ('planning_id', live_id, PARTNER_KEY) token_value = urlquick.get(token_url, max_age=-1) json_parser_token = json.loads(token_value.text) item = Listitem() item.path = live_url item.property[INPUTSTREAM_PROP] = 'inputstream.adaptive' item.property['inputstream.adaptive.manifest_type'] = 'mpd' item.property[ 'inputstream.adaptive.license_type'] = 'com.widevine.alpha' headers2 = { 'customdata': json_parser_token["auth_encoded_xml"], } item.property[ 'inputstream.adaptive.license_key'] = URL_LICENCE_KEY % urlencode( headers2) item.property[ 'inputstream.adaptive.manifest_update_parameter'] = 'full' item.label = get_selected_item_label() item.art.update(get_selected_item_art()) item.info.update(get_selected_item_info()) return item else: return live_url
def get_live_url(plugin, item_id, **kwargs): if get_kodi_version() < 18: xbmcgui.Dialog().ok('Info', plugin.localize(30602)) return False is_helper = inputstreamhelper.Helper('mpd', drm='widevine') if not is_helper.check_inputstream(): return False resp = urlquick.get(URL_LIVE % item_id, max_age=-1) if len(re.compile(r'drmToken\"\:\"(.*?)\"').findall(resp.text)) > 0: token = re.compile(r'drmToken\"\:\"(.*?)\"').findall(resp.text)[0] if len(re.compile(r'streamUrlDash\"\:\"(.*?)\"').findall( resp.text)) > 0: live_url = re.compile(r'streamUrlDash\"\:\"(.*?)\"').findall( resp.text)[0] item = Listitem() item.path = live_url item.label = get_selected_item_label() item.art.update(get_selected_item_art()) item.info.update(get_selected_item_info()) item.property['inputstreamaddon'] = 'inputstream.adaptive' item.property['inputstream.adaptive.manifest_type'] = 'mpd' item.property[ 'inputstream.adaptive.license_type'] = 'com.widevine.alpha' item.property[ 'inputstream.adaptive.license_key'] = URL_LICENCE_KEY % token return item plugin.notify('ERROR', plugin.localize(30713)) return False
def get_video_url(plugin, item_id, data_video_id, **kwargs): if get_kodi_version() < 18: xbmcgui.Dialog().ok('Info', plugin.localize(30602)) return False is_helper = inputstreamhelper.Helper('mpd', drm='widevine') if not is_helper.check_inputstream(): return False # create session request session_requests = requests.session() # Get data_account / data_player resp = session_requests.get(URL_ROOT) data_account_player = re.search('//players\.brightcove\.net/([0-9]+)/([A-Za-z0-9]+)_default/', resp.text) data_account = data_account_player.group(1) data_player = data_account_player.group(2) # Method to get JSON from 'edge.api.brightcove.com' resp2 = session_requests.get( URL_BRIGHTCOVE_VIDEO_JSON % (data_account, data_video_id), headers={ 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.67 Safari/537.36', 'Accept': 'application/json;pk=%s' % (get_brightcove_policy_key(data_account, data_player)) }) json_parser = json.loads(resp2.text) video_url = '' licence_key = '' if 'sources' in json_parser: for url in json_parser["sources"]: if 'src' in url: if 'com.widevine.alpha' in url["key_systems"]: video_url = url["src"] licence_key = url["key_systems"]['com.widevine.alpha'][ 'license_url'] item = Listitem() item.path = video_url item.label = get_selected_item_label() item.art.update(get_selected_item_art()) item.info.update(get_selected_item_info()) item.property[INPUTSTREAM_PROP] = 'inputstream.adaptive' item.property['inputstream.adaptive.manifest_type'] = 'mpd' item.property['inputstream.adaptive.license_type'] = 'com.widevine.alpha' item.property[ 'inputstream.adaptive.license_key'] = licence_key + '|Content-Type=&User-Agent=Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3041.0 Safari/537.36&Host=manifest.prod.boltdns.net|R{SSM}|' return item
def get_video_url(plugin, item_id, video_url, download_mode=False, **kwargs): if get_kodi_version() < 18: xbmcgui.Dialog().ok('Info', plugin.localize(30602)) return False is_helper = inputstreamhelper.Helper('mpd', drm='widevine') if not is_helper.check_inputstream(): return False resp = urlquick.get(video_url, max_age=-1) token_id = re.compile(r'start\-player\.npo\.nl\/embed\/(.*?)\"').findall( resp.text)[0] video_id = re.compile(r'\"iframe\-(.*?)\"').findall(resp.text)[0] resp2 = urlquick.get(URL_STREAM % (video_id, token_id), max_age=-1) json_parser = json.loads(resp2.text) if "html" in json_parser and "Deze video mag niet bekeken worden vanaf jouw locatie" in json_parser[ "html"]: plugin.notify('ERROR', plugin.localize(30713)) return False if "html" in json_parser and "Deze video is niet beschikbaar" in json_parser[ "html"]: plugin.notify('ERROR', plugin.localize(30716)) return False licence_url = json_parser["stream"]["keySystemOptions"][0]["options"][ "licenseUrl"] licence_url_header = json_parser["stream"]["keySystemOptions"][0][ "options"]["httpRequestHeaders"] xcdata_value = licence_url_header["x-custom-data"] item = Listitem() item.path = json_parser["stream"]["src"] item.label = get_selected_item_label() item.art.update(get_selected_item_art()) item.info.update(get_selected_item_info()) if plugin.setting.get_boolean('active_subtitle'): item.subtitles.append(URL_SUBTITLE % video_id) item.property['inputstreamaddon'] = 'inputstream.adaptive' item.property['inputstream.adaptive.manifest_type'] = 'mpd' item.property['inputstream.adaptive.license_type'] = 'com.widevine.alpha' item.property[ 'inputstream.adaptive.license_key'] = licence_url + '|Content-Type=&User-Agent=Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3041.0 Safari/537.36&x-custom-data=%s|R{SSM}|' % xcdata_value return item
def get_video_url(plugin, item_id, video_url, video_id, is_drm, download_mode=False, **kwargs): if 'youtube.com' in video_url: video_id = video_url.rsplit('/', 1)[1] return resolver_proxy.get_stream_youtube(plugin, video_id, download_mode) if 'arte.tv' in video_url: video_id = re.compile("(?<=fr%2F)(.*)(?=&autostart)").findall( video_url)[0] return resolver_proxy.get_arte_video_stream(plugin, 'fr', video_id, download_mode) if is_drm: if get_kodi_version() < 18: xbmcgui.Dialog().ok('Info', plugin.localize(30602)) return False is_helper = inputstreamhelper.Helper('mpd', drm='widevine') if not is_helper.check_inputstream(): return False token_url = URL_TOKEN % ('media_id', video_id, PARTNER_KEY) token_value = urlquick.get(token_url, max_age=-1) json_parser_token = json.loads(token_value.text) item = Listitem() item.path = video_url item.property[INPUTSTREAM_PROP] = 'inputstream.adaptive' item.property['inputstream.adaptive.manifest_type'] = 'mpd' item.property[ 'inputstream.adaptive.license_type'] = 'com.widevine.alpha' headers2 = { 'customdata': json_parser_token["auth_encoded_xml"], } item.property[ 'inputstream.adaptive.license_key'] = URL_LICENCE_KEY % urlencode( headers2) item.property[ 'inputstream.adaptive.manifest_update_parameter'] = 'full' item.label = get_selected_item_label() item.art.update(get_selected_item_art()) item.info.update(get_selected_item_info()) return item return video_url
def get_video_url(plugin, item_id, video_id, download_mode=False, **kwargs): if get_kodi_version() < 18: xbmcgui.Dialog().ok('Info', plugin.localize(30602)) return False is_helper = inputstreamhelper.Helper('mpd', drm='widevine') if not is_helper.check_inputstream(): return False resp = urlquick.get(URL_CLIENT_KEY_VIDEO_JS) client_key_value = 'client-key %s' % re.compile( r'prod\"\,clientKey\:\"(.*?)\"').findall(resp.text)[0] headers = {'Authorization': client_key_value} resp2 = urlquick.get( URL_STREAM_REPLAY % video_id, headers=headers, max_age=-1) json_parser = json.loads(resp2.text) if json_parser["params"] is not None: licence_key_drm = '' for licence_key_drm_datas in json_parser["params"]: if 'widevineLicenseUrl' in licence_key_drm_datas["name"]: licence_key_drm = licence_key_drm_datas["value"] token_drm = '' for token_drm_datas in json_parser["params"]: if 'widevineAuthToken' in token_drm_datas["name"]: token_drm = token_drm_datas["value"] item = Listitem() item.path = json_parser["url"].replace('filter=', 'format=mpd-time-csf,filter=') item.label = get_selected_item_label() item.art.update(get_selected_item_art()) item.info.update(get_selected_item_info()) item.property['inputstreamaddon'] = 'inputstream.adaptive' item.property['inputstream.adaptive.manifest_type'] = 'mpd' item.property[ 'inputstream.adaptive.license_type'] = 'com.widevine.alpha' item.property[ 'inputstream.adaptive.license_key'] = licence_key_drm + '|Content-Type=&User-Agent=Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3041.0 Safari/537.36&Authorization=%s|R{SSM}|' % token_drm return item plugin.notify('ERROR', plugin.localize(30713)) return False
def get_video_url(plugin, item_id, video_id, download_mode=False, **kwargs): resp = urlquick.get(URL_STREAM % video_id, max_age=-1) json_parser = json.loads(resp.text) if 'error' in json_parser: if json_parser["error"] is not None: if json_parser["error"]["status"] == '403': plugin.notify('ERROR', plugin.localize(30713)) else: plugin.notify('ERROR', plugin.localize(30716)) return False if 'drmToken' in json_parser["playback"]: if get_kodi_version() < 18: xbmcgui.Dialog().ok('Info', plugin.localize(30602)) return False is_helper = inputstreamhelper.Helper('mpd', drm='widevine') if not is_helper.check_inputstream(): return False if download_mode: xbmcgui.Dialog().ok('Info', plugin.localize(30603)) return False token = json_parser["playback"]["drmToken"] item = Listitem() item.path = json_parser["playback"]["streamUrlDash"] item.label = get_selected_item_label() item.art.update(get_selected_item_art()) item.info.update(get_selected_item_info()) item.property['inputstreamaddon'] = 'inputstream.adaptive' item.property['inputstream.adaptive.manifest_type'] = 'mpd' item.property[ 'inputstream.adaptive.license_type'] = 'com.widevine.alpha' item.property[ 'inputstream.adaptive.license_key'] = URL_LICENCE_KEY % token return item else: final_video_url = json_parser["playback"]["streamUrlHls"] if download_mode: return download.download_video(final_video_url) return final_video_url
def list_videos(plugin, item_id, program_id, sub_category_id, **kwargs): if sub_category_id is None: url = URL_VIDEOS2 % program_id else: url = URL_VIDEOS % (program_id, sub_category_id) resp = urlquick.get(url, headers={ 'User-Agent': web_utils.get_random_ua(), 'x-customer-name': 'rtlbe' }) json_parser = resp.json() if not json_parser: plugin.notify(plugin.localize(30718), '') yield False at_least_one_item = False for video in json_parser: video_id = str(video['id']) item = Listitem() at_least_one_item = True item.label = video['title'] is_downloadable = False if get_kodi_version() < 18: is_downloadable = True if 'type' in video and video['type'] == 'playlist': populate_item(item, video) item.set_callback(get_playlist_urls, item_id=item_id, video_id=video_id, url=url) else: populate_item(item, video['clips'][0]) item.set_callback(get_video_url, item_id=item_id, video_id=video_id) item_post_treatment(item, is_playable=True, is_downloadable=is_downloadable) yield item if not at_least_one_item: plugin.notify(plugin.localize(30718), '') yield False
def list_videos(plugin, item_id, program_id, sub_category_id, **kwargs): url = '' if sub_category_id is None: url = URL_VIDEOS2 % program_id else: url = URL_VIDEOS % (program_id, sub_category_id) resp = urlquick.get(url) json_parser = json.loads(resp.text) if not json_parser: plugin.notify(plugin.localize(30718), '') yield False for video in json_parser: video_id = str(video['id']) item = Listitem() item.label = video['title'] is_downloadable = False if get_kodi_version() < 18: is_downloadable = True if 'type' in video and video['type'] == 'playlist': populate_item(item, video) item.set_callback(get_playlist_urls, item_id=item_id, video_id=video_id, url=url) else: populate_item(item, video['clips'][0]) item.set_callback(get_video_url, item_id=item_id, video_id=video_id) item_post_treatment(item, is_playable=True, is_downloadable=is_downloadable) yield item
def get_sorted_menu(plugin, menu_id): """Get ordered 'menu_id' menu without disabled and hidden items Args: plugin (codequick.script.Script) menu_id (str): Menu to get (e.g. root) Returns: list<tuple> List of items (item_order, item_id, item_infos) """ # The current menu to build contains # all the items present in the 'menu_id' # skeleton file current_menu = importlib.import_module('resources.lib.skeletons.' + menu_id).menu # Notify user for the new M3U Live TV feature if menu_id == "live_tv" and \ get_kodi_version() >= 18 and \ plugin.setting.get_boolean('show_live_tv_m3u_info'): r = xbmcgui.Dialog().yesno(plugin.localize(30600), plugin.localize(30605), plugin.localize(30606)) if not r: plugin.setting['show_live_tv_m3u_info'] = False # Keep in memory the first menu taken # in order to provide a prefix when the user # add a favourite fav.guess_fav_prefix(menu_id) # First, we have to sort the current menu items # according to each item order and we have # to hide each disabled item menu = [] for item_id, item_infos in list(current_menu.items()): add_item = True # If the item is disabled in skeleton file # (e.g. if a channel is not available anymore) if item_infos['enabled'] is False: add_item = False # If the item is hidden by the user setting if is_item_hidden(item_id, menu_id): add_item = False # If the desired language is not available if 'available_languages' in item_infos: desired_language = utils.ensure_unicode(Script.setting[item_id + '.language']) if desired_language not in item_infos['available_languages']: add_item = False if add_item: item_order = get_item_order(item_id, menu_id, item_infos) item = (item_order, item_id, item_infos) menu.append(item) # We sort the menu according to the item_order values return sorted(menu, key=lambda x: x[0])
def get_live_url(plugin, item_id, **kwargs): if get_kodi_version() < 18: xbmcgui.Dialog().ok('Info', plugin.localize(30602)) return False is_helper = inputstreamhelper.Helper('mpd', drm='widevine') if not is_helper.check_inputstream(): return False # create session request session_requests = requests.session() session_requests.get(URL_LOGIN_MODAL) resptokenid = session_requests.get(URL_LOGIN_TOKEN) token_id = re.compile(r'tokenId: \'(.*?)\'').findall(resptokenid.text)[2] if plugin.setting.get_string( 'uktvplay.login') == '' or plugin.setting.get_string( 'uktvplay.password') == '': xbmcgui.Dialog().ok('Info', plugin.localize(30604) % ('UKTVPlay', 'https://uktvplay.uktv.co.uk')) return False # Build PAYLOAD payload = { 'email': plugin.setting.get_string('uktvplay.login'), 'password': plugin.setting.get_string('uktvplay.password') } payload = json.dumps(payload) # LOGIN # KO - resp2 = session_urlquick.post( # URL_COMPTE_LOGIN, data=payload, # headers={'User-Agent': web_utils.get_ua, 'referer': URL_COMPTE_LOGIN}) resplogin = session_requests.post( URL_COMPTE_LOGIN, data=payload, headers={ 'Accept': 'application/json, text/plain, */*', 'Content-Type': 'application/json;charset=UTF-8', 'Origin': 'https://uktvplay.uktv.co.uk', 'Referer': 'https://uktvplay.uktv.co.uk/account/', 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36', 'X-TokenId': token_id, 'X-Version': '9.0.0' }) if resplogin.status_code >= 400: plugin.notify('ERROR', 'UKTVPlay : ' + plugin.localize(30711)) return False json_parser_resplogin = json.loads(resplogin.content) if 'home_uktvplay' in item_id: channel_uktvplay_id = 'home' else: channel_uktvplay_id = item_id respdatachannel = session_requests.get(URL_LIVE % channel_uktvplay_id) data_channel = re.compile(r'data\-channel\=\"(.*?)\"').findall( respdatachannel.text)[0] respkey = session_requests.get(URL_LIVE_KEY) app_key = re.compile(r'app\_key"\ \: \"(.*?)\"').findall(respkey.text)[0] resptoken = session_requests.get(URL_LIVE_TOKEN % data_channel) json_parser_resptoken = json.loads(resptoken.text) respstreamdatas = session_requests.post( URL_STREAM_LIVE % (data_channel, app_key, str(json_parser_resplogin["accountId"])), headers={ 'Token-Expiry': json_parser_resptoken["expiry"], 'Token': json_parser_resptoken["token"], 'Uvid': data_channel, 'Userid': str(json_parser_resplogin["accountId"]) }) json_parser = json.loads(respstreamdatas.text) item = Listitem() item.path = json_parser["response"]["drm"]["widevine"]["stream"] item.label = get_selected_item_label() item.art.update(get_selected_item_art()) item.info.update(get_selected_item_info()) item.property[INPUTSTREAM_PROP] = 'inputstream.adaptive' item.property['inputstream.adaptive.manifest_type'] = 'mpd' item.property['inputstream.adaptive.license_type'] = 'com.widevine.alpha' item.property[ 'inputstream.adaptive.license_key'] = json_parser["response"]["drm"]["widevine"]["licenseAcquisitionUrl"] + '|Content-Type=&User-Agent=Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3041.0 Safari/537.36|R{SSM}|' return item
def get_live_url(plugin, item_id, **kwargs): resp = urlquick.get(URL_LIVE_JSON % (item_id[:3], item_id[:3])) json_parser = json.loads(resp.text) live_id = '' for live_datas in json_parser["data"]: if live_datas["title"] in LIVE_LIVE_CHANNEL_NAME[item_id]: live_id = live_datas["id"] if live_id is None: # Add Notification return False resp2 = urlquick.get(URL_INFO_VIDEO % (item_id[:3], live_id)) json_parser2 = json.loads(resp2.text) # build stream_url stream_url = '' is_drm = False for stream_datas in json_parser2["chapterList"]: if live_id in stream_datas["id"]: for stream_datas_url in stream_datas["resourceList"]: if 'drmList' in stream_datas_url: is_drm = True if is_drm: if get_kodi_version() < 18: xbmcgui.Dialog().ok(plugin.localize(14116), plugin.localize(30602)) return False is_helper = inputstreamhelper.Helper('mpd', drm='widevine') if not is_helper.check_inputstream(): return False licence_drm_url = '' for stream_datas in json_parser2["chapterList"]: if live_id in stream_datas["id"]: for stream_datas_url in stream_datas["resourceList"]: stream_url = stream_datas_url["url"] for licence_drm_datas in stream_datas_url["drmList"]: if 'WIDEVINE' in licence_drm_datas["type"]: licence_drm_url = licence_drm_datas["licenseUrl"] item = Listitem() item.path = stream_url item.property[INPUTSTREAM_PROP] = 'inputstream.adaptive' item.property['inputstream.adaptive.manifest_type'] = 'mpd' item.property[ 'inputstream.adaptive.license_type'] = 'com.widevine.alpha' item.property[ 'inputstream.adaptive.license_key'] = licence_drm_url + '|Content-Type=&User-Agent=Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3041.0 Safari/537.36&Host=srg.live.ott.irdeto.com|R{SSM}|' item.property[ 'inputstream.adaptive.manifest_update_parameter'] = 'full' item.label = get_selected_item_label() item.art.update(get_selected_item_art()) item.info.update(get_selected_item_info()) return item else: for stream_datas in json_parser2["chapterList"]: if live_id in stream_datas["id"]: for stream_datas_url in stream_datas["resourceList"]: if 'HD' in stream_datas_url["quality"] and \ 'mpegURL' in stream_datas_url["mimeType"]: stream_url = stream_datas_url["url"] break else: if 'mpegURL' in stream_datas_url["mimeType"]: stream_url = stream_datas_url["url"] acl_value = '/i/%s/*' % ( re.compile(r'\/i\/(.*?)\/').findall(stream_url)[0]) token_datas = urlquick.get(URL_TOKEN % acl_value, max_age=-1) token_jsonparser = json.loads(token_datas.text) token = token_jsonparser["token"]["authparams"] if '?' in stream_url: final_video_url = stream_url + '&' + token else: final_video_url = stream_url + '?' + token return final_video_url
def list_videos(plugin, item_id, program_id, sub_category_id, **kwargs): url = '' if sub_category_id is None: url = URL_VIDEOS2 % program_id else: url = URL_VIDEOS % (program_id, sub_category_id) resp = urlquick.get(url, headers={ 'User-Agent': web_utils.get_random_ua(), 'x-customer-name': 'rtlbe' }) json_parser = json.loads(resp.text) # TO DO Playlist More one 'clips' at_least_one_item = False for video in json_parser: video_id = str(video['id']) title = video['title'] duration = video['clips'][0]['duration'] description = '' if 'description' in video: description = video['description'] try: aired = video['clips'][0]['product']['last_diffusion'] aired = aired aired = aired[:10] # year = aired[:4] # date : string (%d.%m.%Y / 01.01.2009) # aired : string (2008-12-07) # day = aired.split('-')[2] # mounth = aired.split('-')[1] # year = aired.split('-')[0] # date = '.'.join((day, mounth, year)) except Exception: aired = '' # year = '' # date = '' img = '' program_imgs = video['clips'][0]['images'] program_img = '' for img in program_imgs: if img['role'] == 'vignette': external_key = img['external_key'] program_img = URL_IMG % (external_key) item = Listitem() at_least_one_item = True item.label = title item.info['plot'] = description item.info['duration'] = duration item.art['thumb'] = item.art['landscape'] = program_img item.art['fanart'] = program_img try: item.info.date(aired, '%Y-%m-%d') except Exception: pass is_downloadable = False if get_kodi_version() < 18: is_downloadable = True item.set_callback(get_video_url, item_id=item_id, video_id=video_id) item_post_treatment(item, is_playable=True, is_downloadable=is_downloadable) yield item if not at_least_one_item: plugin.notify(plugin.localize(LABELS['No videos found']), '') yield False
def get_video_url(plugin, item_id, video_url, download_mode=False, **kwargs): resp = urlquick.get(video_url, headers={'User-Agent': web_utils.get_random_ua()}, max_age=-1) if len(re.compile(r'www.wat.tv/embedframe/(.*?)[\"\?]').findall(resp.text)) > 0: video_id = re.compile(r'www.wat.tv/embedframe/(.*?)[\"\?]').findall( resp.text)[0] url_wat_embed = URL_WAT_BY_ID % video_id wat_embed_html = urlquick.get( url_wat_embed, headers={'User-Agent': web_utils.get_random_ua()}, max_age=-1) stream_id = re.compile('UVID=(.*?)&').findall(wat_embed_html.text)[0] url_json = URL_VIDEO_STREAM_WAT % stream_id htlm_json = urlquick.get(url_json, headers={'User-Agent': web_utils.get_random_ua()}, max_age=-1) json_parser = json.loads(htlm_json.text) # Check DRM in the m3u8 file manifest = urlquick.get(json_parser["hls"], headers={'User-Agent': web_utils.get_random_ua()}, max_age=-1) if 'drm' in manifest: Script.notify("TEST", plugin.localize(30702), Script.NOTIFY_INFO) return False root = os.path.dirname(json_parser["hls"]) manifest = urlquick.get(json_parser["hls"].split('&max_bitrate=')[0], headers={'User-Agent': web_utils.get_random_ua()}, max_age=-1) lines = manifest.text.splitlines() final_video_url = '' all_datas_videos_quality = [] all_datas_videos_path = [] for k in range(0, len(lines) - 1): if 'RESOLUTION=' in lines[k]: all_datas_videos_quality.append( re.compile(r'RESOLUTION=(.*?)$').findall(lines[k])[0].split(',')[0]) all_datas_videos_path.append(root + '/' + lines[k + 1]) if DESIRED_QUALITY == "DIALOG": seleted_item = xbmcgui.Dialog().select( plugin.localize(30709), all_datas_videos_quality) final_video_url = all_datas_videos_path[seleted_item] elif DESIRED_QUALITY == 'BEST': # Last video in the Best for k in all_datas_videos_path: url = k final_video_url = url else: final_video_url = all_datas_videos_path[0] if download_mode: return download.download_video(final_video_url) return final_video_url else: video_id = re.compile(r'tf1.fr/embedplayer/(.*?)[\"\?]').findall( resp.text)[0] video_format = 'hls' url_json = URL_VIDEO_STREAM % (video_id, video_format) htlm_json = urlquick.get(url_json, headers={'User-Agent': web_utils.get_random_ua()}, max_age=-1) json_parser = json.loads(htlm_json.text) if json_parser['code'] >= 400: plugin.notify('ERROR', plugin.localize(30716)) return False # Check DRM in the m3u8 file manifest = urlquick.get(json_parser["url"], headers={ 'User-Agent': web_utils.get_random_ua()}, max_age=-1).text if 'drm' in manifest: if get_kodi_version() < 18: xbmcgui.Dialog().ok('Info', plugin.localize(30602)) return False else: video_format = 'dash' if video_format == 'hls': final_video_url = json_parser["url"].replace('2800000', '4000000') if download_mode: return download.download_video(final_video_url) return final_video_url else: if download_mode: xbmcgui.Dialog().ok('Info', plugin.localize(30603)) return False url_json = URL_VIDEO_STREAM % (video_id, video_format) htlm_json = urlquick.get( url_json, headers={'User-Agent': web_utils.get_random_ua()}, max_age=-1) json_parser = json.loads(htlm_json.text) is_helper = inputstreamhelper.Helper('mpd', drm='widevine') if not is_helper.check_inputstream(): return False item = Listitem() item.path = json_parser["url"] item.label = get_selected_item_label() item.art.update(get_selected_item_art()) item.info.update(get_selected_item_info()) item.property['inputstreamaddon'] = 'inputstream.adaptive' item.property['inputstream.adaptive.manifest_type'] = 'mpd' item.property[ 'inputstream.adaptive.license_type'] = 'com.widevine.alpha' item.property[ 'inputstream.adaptive.license_key'] = URL_LICENCE_KEY % video_id return item
def get_video_url(plugin, item_id, video_id, download_mode=False, **kwargs): if item_id == 'swissinfo': channel_name_value = 'swi' else: channel_name_value = item_id resp = urlquick.get(URL_INFO_VIDEO % (channel_name_value, video_id)) json_parser = json.loads(resp.text) # build stream_url is_drm = False for stream_datas in json_parser["chapterList"]: if video_id in stream_datas["id"]: for stream_datas_url in stream_datas["resourceList"]: if 'drmList' in stream_datas_url: is_drm = True if is_drm: if get_kodi_version() < 18: xbmcgui.Dialog().ok(plugin.localize(14116), plugin.localize(30602)) return False is_helper = inputstreamhelper.Helper('mpd', drm='widevine') if not is_helper.check_inputstream(): return False if download_mode: return False licence_drm_url = '' for stream_datas in json_parser["chapterList"]: if video_id in stream_datas["id"]: for stream_datas_url in stream_datas["resourceList"]: if 'DASH' in stream_datas_url["streaming"]: stream_url = stream_datas_url["url"] for licence_drm_datas in stream_datas_url["drmList"]: if 'WIDEVINE' in licence_drm_datas["type"]: licence_drm_url = licence_drm_datas[ "licenseUrl"] item = Listitem() item.path = stream_url item.property[INPUTSTREAM_PROP] = 'inputstream.adaptive' item.property['inputstream.adaptive.manifest_type'] = 'mpd' item.property[ 'inputstream.adaptive.license_type'] = 'com.widevine.alpha' item.property[ 'inputstream.adaptive.license_key'] = licence_drm_url + '|Content-Type=&User-Agent=Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3041.0 Safari/537.36&Host=srg.live.ott.irdeto.com|R{SSM}|' item.label = get_selected_item_label() item.art.update(get_selected_item_art()) item.info.update(get_selected_item_info()) return item else: stream_url = '' for stream_datas in json_parser["chapterList"]: if video_id in stream_datas["id"]: is_token = False for stream_datas_url in stream_datas["resourceList"]: if stream_datas_url['tokenType'] == 'NONE': stream_url = stream_datas_url['url'] else: is_token = True if 'HD' in stream_datas_url["quality"] and \ 'mpegURL' in stream_datas_url["mimeType"]: stream_url = stream_datas_url["url"] break else: if 'mpegURL' in stream_datas_url["mimeType"]: stream_url = stream_datas_url["url"] if is_token: acl_value = '/i/%s/*' % (re.compile( r'\/i\/(.*?)\/master').findall(stream_url)[0]) token_datas = urlquick.get(URL_TOKEN % acl_value, max_age=-1) token_jsonparser = json.loads(token_datas.text) token = token_jsonparser["token"]["authparams"] if '?' in stream_datas_url['url']: stream_url = stream_url + '&' + token else: stream_url = stream_url + '?' + token if download_mode: return download.download_video(stream_url) return stream_url
def get_video_url(plugin, item_id, next_url, download_mode=False, **kwargs): if 'tokenCMS' in next_url: if get_kodi_version() < 18: xbmcgui.Dialog().ok('Info', plugin.localize(30602)) return False is_helper = inputstreamhelper.Helper('mpd', drm='widevine') if not is_helper.check_inputstream(): return False if download_mode: xbmcgui.Dialog().ok('Info', plugin.localize(30603)) return False # Get DeviceId (not a good device ID => TODO find the good one to fix to get licence key) ############################################################################## # Code by mtr81 : https://github.com/xbmc/inputstream.adaptive/issues/812 def rnd(): return str( hex(math.floor((1 + random.random()) * 9007199254740991)))[4:] ts = int(1000 * time.time()) deviceKeyId = str(ts) + '-' + rnd() device_id_first = deviceKeyId + ':0:' + str(ts + 2000) + '-' + rnd() sessionId = str(ts + 3000) + '-' + rnd() ############################################################################## # Get Portail Id session_requests = requests.session() resp_app_config = session_requests.get(URL_REPLAY % item_id) json_app_config = re.compile('window.app_config=(.*?)};').findall( resp_app_config.text)[0] json_app_config_parser = json.loads(json_app_config + ('}')) portail_id = json_app_config_parser["api"]["pass"][ "portailIdEncrypted"] headers = { 'User-Agent': web_utils.get_random_ua(), 'Origin': 'https://www.canalplus.com', 'Referer': 'https://www.canalplus.com/', } # Get PassToken payload = { 'deviceId': device_id_first, 'vect': 'INTERNET', 'media': 'web', 'portailId': portail_id, 'sessionId': sessionId, } resp_token_mycanal = session_requests.post(URL_TOKEN, data=payload, headers=headers) json_token_parser = resp_token_mycanal.json() pass_token = json_token_parser["response"]["passToken"] device_id = json_token_parser["response"]["userData"][ "deviceId"].split(':')[0] video_id = next_url.split('/')[-1].split('.json')[0] headers = { 'Accept': 'application/json, text/plain, */*', 'Authorization': 'PASS Token="%s"' % pass_token, 'Content-Type': 'application/json; charset=UTF-8', 'XX-DEVICE': 'pc %s' % device_id, 'XX-DOMAIN': 'cpfra', 'XX-OPERATOR': 'pc', 'XX-Profile-Id': '0', 'XX-SERVICE': 'mycanal', 'User-Agent': web_utils.get_random_ua(), } value_datas_json = session_requests.get(URL_VIDEO_DATAS % video_id, headers=headers) value_datas_jsonparser = value_datas_json.json() comMode_value = '' contentId_value = '' distMode_value = '' distTechnology_value = '' drmType_value = '' functionalType_value = '' hash_value = '' idKey_value = '' quality_value = '' if 'available' not in value_datas_jsonparser: # Some videos required an account # Get error return False is_video_drm = True for stream_datas in value_datas_jsonparser["available"]: if 'stream' not in stream_datas['distTechnology']: continue if 'DRM' in stream_datas['drmType']: continue comMode_value = stream_datas['comMode'] contentId_value = stream_datas['contentId'] distMode_value = stream_datas['distMode'] distTechnology_value = stream_datas['distTechnology'] drmType_value = stream_datas['drmType'] functionalType_value = stream_datas['functionalType'] hash_value = stream_datas['hash'] idKey_value = stream_datas['idKey'] quality_value = stream_datas['quality'] is_video_drm = False if is_video_drm: for stream_datas in value_datas_jsonparser["available"]: if 'stream' not in stream_datas['distTechnology']: continue if 'Widevine' not in stream_datas['drmType']: continue comMode_value = stream_datas['comMode'] contentId_value = stream_datas['contentId'] distMode_value = stream_datas['distMode'] distTechnology_value = stream_datas['distTechnology'] drmType_value = stream_datas['drmType'] functionalType_value = stream_datas['functionalType'] hash_value = stream_datas['hash'] idKey_value = stream_datas['idKey'] quality_value = stream_datas['quality'] payload = { 'comMode': comMode_value, 'contentId': contentId_value, 'distMode': distMode_value, 'distTechnology': distTechnology_value, 'drmType': drmType_value, 'functionalType': functionalType_value, 'hash': hash_value, 'idKey': idKey_value, 'quality': quality_value, } payload = json.dumps(payload) headers = { 'Accept': 'application/json, text/plain, */*', 'Authorization': 'PASS Token="%s"' % pass_token, 'Content-Type': 'application/json; charset=UTF-8', 'XX-DEVICE': 'pc %s' % device_id, 'XX-DOMAIN': 'cpfra', 'XX-OPERATOR': 'pc', 'XX-Profile-Id': '0', 'XX-SERVICE': 'mycanal', 'User-Agent': web_utils.get_random_ua(), } resp_stream_datas = session_requests.put(URL_STREAM_DATAS, data=payload, headers=headers) jsonparser_stream_datas = resp_stream_datas.json() resp_real_stream_datas = session_requests.get( jsonparser_stream_datas['@medias'], headers=headers) jsonparser_real_stream_datas = resp_real_stream_datas.json() subtitle_url = '' item = Listitem() if 'VM' in jsonparser_real_stream_datas: item.path = jsonparser_real_stream_datas["VM"][0]["media"][0][ "distribURL"] + '/manifest' if plugin.setting.get_boolean('active_subtitle'): for asset in jsonparser_real_stream_datas["VM"][0]["files"]: if 'vtt' in asset["mimeType"]: subtitle_url = asset['distribURL'] else: item.path = jsonparser_real_stream_datas["VF"][0]["media"][0][ "distribURL"] + '/manifest' if plugin.setting.get_boolean('active_subtitle'): for asset in jsonparser_real_stream_datas["VF"][0]["files"]: if 'vtt' in asset["mimeType"]: subtitle_url = asset['distribURL'] item.label = get_selected_item_label() item.art.update(get_selected_item_art()) item.info.update(get_selected_item_info()) item.property[INPUTSTREAM_PROP] = 'inputstream.adaptive' item.property['inputstream.adaptive.manifest_type'] = 'ism' if 'http' in subtitle_url: item.subtitles.append(subtitle_url) if 'Widevine' in drmType_value: # DRM Message (TODO to find a way to get licence key) Script.notify("INFO", plugin.localize(30702), Script.NOTIFY_INFO) return False item.property[ 'inputstream.adaptive.license_type'] = 'com.widevine.alpha' item.property[ 'inputstream.adaptive.license_type'] = 'com.widevine.alpha' headers2 = { 'Accept': 'application/json, text/plain, */*', 'Authorization': 'PASS Token="%s"' % pass_token, 'Content-Type': 'text/plain', 'User-Agent': web_utils.get_random_ua(), 'Origin': 'https://www.mycanal.fr', 'XX-DEVICE': 'pc %s' % device_id, 'XX-DOMAIN': 'cpfra', 'XX-OPERATOR': 'pc', 'XX-Profile-Id': '0', 'XX-SERVICE': 'mycanal', } # Return HTTP 200 but the response is not correctly interpreted by inputstream (https://github.com/peak3d/inputstream.adaptive/issues/267) item.property[ 'inputstream.adaptive.license_key'] = jsonparser_stream_datas[ '@licence'] + '?drmConfig=mkpl::false' + '|%s|R{SSM}|' % urlencode( headers2) return item resp = urlquick.get(next_url, headers={'User-Agent': web_utils.get_random_ua()}, max_age=-1) json_parser = resp.json() return json_parser["detail"]["informations"]["playsets"]["available"][0][ "videoURL"]
def get_video_url(plugin, item_id, video_id, download_mode=False, **kwargs): if get_kodi_version() < 18: xbmcgui.Dialog().ok('Info', plugin.localize(30602)) return False is_helper = inputstreamhelper.Helper('mpd', drm='widevine') if not is_helper.check_inputstream(): return False headers = {'X-Requested-With': 'XMLHttpRequest'} resp_token = urlquick.get(URL_TOKEN_API, headers=headers, max_age=-1) session_token = resp_token.cookies['npo_session'] json_parser_token = json.loads(resp_token.text) api_token = json_parser_token['token'] # Build PAYLOAD payload = {"_token": api_token} cookies = {"npo_session": session_token} resp2 = urlquick.post(URL_TOKEN_ID % video_id, cookies=cookies, data=payload, max_age=-1) json_parser = json.loads(resp2.text) token_id = json_parser['token'] resp3 = urlquick.get(URL_STREAM % (video_id, token_id), max_age=-1) json_parser2 = json.loads(resp3.text) if "html" in json_parser2 and "Dit programma mag niet bekeken worden vanaf jouw locatie (33)." in json_parser2[ "html"]: plugin.notify('ERROR', plugin.localize(30713)) return False elif "html" in json_parser2 and "Dit programma is niet (meer) beschikbaar (15)." in json_parser2[ "html"]: plugin.notify('ERROR', plugin.localize(30710)) return False licence_url = json_parser2["stream"]["keySystemOptions"][0]["options"][ "licenseUrl"] licence_url_header = json_parser2["stream"]["keySystemOptions"][0][ "options"]["httpRequestHeaders"] xcdata_value = licence_url_header["x-custom-data"] item = Listitem() item.path = json_parser2["stream"]["src"] item.label = get_selected_item_label() item.art.update(get_selected_item_art()) item.info.update(get_selected_item_info()) if plugin.setting.get_boolean('active_subtitle'): item.subtitles.append(URL_SUBTITLE % video_id) item.property[INPUTSTREAM_PROP] = 'inputstream.adaptive' item.property['inputstream.adaptive.manifest_type'] = 'mpd' item.property['inputstream.adaptive.license_type'] = 'com.widevine.alpha' item.property[ 'inputstream.adaptive.license_key'] = licence_url + '|Content-Type=&User-Agent=Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3041.0 Safari/537.36&x-custom-data=%s|R{SSM}|' % xcdata_value return item
def get_video_url(plugin, item_id, data_video_id, **kwargs): if get_kodi_version() < 18: xbmcgui.Dialog().ok('Info', plugin.localize(30602)) return False is_helper = inputstreamhelper.Helper('mpd', drm='widevine') if not is_helper.check_inputstream(): return False # create session request session_requests = requests.session() # Get data_account / data_player resp = session_requests.get(URL_ROOT) js_id_all = re.compile(r'uktv\-static\/prod\/play\/(.*?)\.js').findall( resp.text) for js_id in js_id_all: resp2 = session_requests.get(URL_BRIGHTCOVE_DATAS % js_id) if len( re.compile(r'VUE_APP_BRIGHTCOVE_ACCOUNT\:\"(.*?)\"').findall( resp2.text)) > 0: data_account = re.compile( r'VUE_APP_BRIGHTCOVE_ACCOUNT\:\"(.*?)\"').findall( resp2.text)[0] data_player = re.compile( r'VUE_APP_BRIGHTCOVE_PLAYER\:\"(.*?)\"').findall(resp2.text)[0] break # Method to get JSON from 'edge.api.brightcove.com' resp3 = session_requests.get( URL_BRIGHTCOVE_VIDEO_JSON % (data_account, data_video_id), headers={ 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.67 Safari/537.36', 'Accept': 'application/json;pk=%s' % (get_brightcove_policy_key(data_account, data_player)) }) json_parser = json.loads(resp3.text) video_url = '' licence_key = '' if 'sources' in json_parser: for url in json_parser["sources"]: if 'src' in url: if 'com.widevine.alpha' in url["key_systems"]: video_url = url["src"] licence_key = url["key_systems"]['com.widevine.alpha'][ 'license_url'] item = Listitem() item.path = video_url item.label = get_selected_item_label() item.art.update(get_selected_item_art()) item.info.update(get_selected_item_info()) item.property['inputstreamaddon'] = 'inputstream.adaptive' item.property['inputstream.adaptive.manifest_type'] = 'mpd' item.property['inputstream.adaptive.license_type'] = 'com.widevine.alpha' item.property[ 'inputstream.adaptive.license_key'] = licence_key + '|Content-Type=&User-Agent=Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3041.0 Safari/537.36&Host=manifest.prod.boltdns.net|R{SSM}|' return item
def get_video_url(plugin, item_id, video_id, download_mode=False, **kwargs): if get_kodi_version() < 18: video_json = urlquick.get(URL_JSON_VIDEO % video_id, headers={ 'User-Agent': web_utils.get_random_ua(), 'x-customer-name': 'm6web' }, max_age=-1) json_parser = json.loads(video_json.text) video_assets = json_parser['clips'][0]['assets'] if video_assets is None: plugin.notify('ERROR', plugin.localize(30721)) return False final_video_url = '' all_datas_videos_quality = [] all_datas_videos_path = [] for asset in video_assets: if 'http_h264' in asset["type"]: all_datas_videos_quality.append(asset["video_quality"]) all_datas_videos_path.append(asset['full_physical_path']) elif 'h264' in asset["type"]: manifest = urlquick.get( asset['full_physical_path'], headers={'User-Agent': web_utils.get_random_ua()}, max_age=-1) if 'drm' not in manifest.text: all_datas_videos_quality.append(asset["video_quality"]) all_datas_videos_path.append(asset['full_physical_path']) if len(all_datas_videos_quality) == 0: xbmcgui.Dialog().ok('Info', plugin.localize(30602)) return False elif len(all_datas_videos_quality) == 1: final_video_url = all_datas_videos_path[0] else: if DESIRED_QUALITY == "DIALOG": seleted_item = xbmcgui.Dialog().select( plugin.localize(30709), all_datas_videos_quality) if seleted_item == -1: return False return all_datas_videos_path[seleted_item] elif DESIRED_QUALITY == "BEST": url_best = '' i = 0 for data_video in all_datas_videos_quality: if 'lq' not in data_video: url_best = all_datas_videos_path[i] i = i + 1 final_video_url = url_best else: final_video_url = all_datas_videos_path[0] if download_mode: return download.download_video(final_video_url) return final_video_url else: resp_js_id = urlquick.get(URL_GET_JS_ID_API_KEY) js_id = re.compile(r'client\-(.*?)\.bundle\.js').findall( resp_js_id.text)[0] resp = urlquick.get(URL_API_KEY % js_id) api_key = re.compile(r'\"eu1.gigya.com\"\,key\:\"(.*?)\"').findall( resp.text)[0] if plugin.setting.get_string('6play.login') == '' or\ plugin.setting.get_string('6play.password') == '': xbmcgui.Dialog().ok( 'Info', plugin.localize(30604) % ('6play', 'https://www.6play.fr')) return False # Build PAYLOAD payload = { "loginID": plugin.setting.get_string('6play.login'), "password": plugin.setting.get_string('6play.password'), "apiKey": api_key, "format": "jsonp", "callback": "jsonp_3bbusffr388pem4" } # LOGIN resp2 = urlquick.post(URL_COMPTE_LOGIN, data=payload, headers={ 'User-Agent': web_utils.get_random_ua(), 'referer': 'https://www.6play.fr/connexion' }) json_parser = json.loads( resp2.text.replace('jsonp_3bbusffr388pem4(', '').replace(');', '')) if "UID" not in json_parser: plugin.notify('ERROR', '6play : ' + plugin.localize(30711)) return False account_id = json_parser["UID"] account_timestamp = json_parser["signatureTimestamp"] account_signature = json_parser["UIDSignature"] is_helper = inputstreamhelper.Helper('mpd', drm='widevine') if not is_helper.check_inputstream(): return False # Build PAYLOAD headers payload_headers = { 'x-auth-gigya-signature': account_signature, 'x-auth-gigya-signature-timestamp': account_timestamp, 'x-auth-gigya-uid': account_id, 'x-customer-name': 'm6web' } token_json = urlquick.get(URL_TOKEN_DRM % (account_id, video_id), headers=payload_headers, max_age=-1) token_jsonparser = json.loads(token_json.text) token = token_jsonparser["token"] video_json = urlquick.get(URL_JSON_VIDEO % video_id, headers={ 'User-Agent': web_utils.get_random_ua(), 'x-customer-name': 'm6web' }, max_age=-1) json_parser = json.loads(video_json.text) video_assets = json_parser['clips'][0]['assets'] if video_assets is None: plugin.notify('ERROR', plugin.localize(30721)) return False subtitle_url = '' if plugin.setting.get_boolean('active_subtitle'): for asset in video_assets: if 'subtitle_vtt' in asset["type"]: subtitle_url = asset['full_physical_path'] for asset in video_assets: if 'usp_dashcenc_h264' in asset["type"]: item = Listitem() item.path = asset['full_physical_path'] if 'http' in subtitle_url: item.subtitles.append(subtitle_url) item.label = get_selected_item_label() item.art.update(get_selected_item_art()) item.info.update(get_selected_item_info()) item.property['inputstreamaddon'] = 'inputstream.adaptive' item.property['inputstream.adaptive.manifest_type'] = 'mpd' item.property[ 'inputstream.adaptive.license_type'] = 'com.widevine.alpha' item.property[ 'inputstream.adaptive.license_key'] = URL_LICENCE_KEY % token return item for asset in video_assets: if 'http_h264' in asset["type"]: if "hd" in asset["video_quality"]: item = Listitem() item.path = asset['full_physical_path'] if 'http' in subtitle_url: item.subtitles.append(subtitle_url) item.label = get_selected_item_label() item.art.update(get_selected_item_art()) item.info.update(get_selected_item_info()) return item return False
def get_video_url(plugin, item_id, video_id, download_mode=False, **kwargs): if get_kodi_version() < 18: xbmcgui.Dialog().ok(plugin.localize(14116), plugin.localize(30602)) return False is_helper = inputstreamhelper.Helper('mpd', drm='widevine') if not is_helper.check_inputstream(): return False headers_auth = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:97.0) Gecko/20100101 Firefox/97.0", "Accept": "application/json, text/plain, */*", "Accept-Language": "fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3", "Content-Type": "application/json;charset=utf-8", "Sec-Fetch-Dest": "empty", "Sec-Fetch-Mode": "cors", "Sec-Fetch-Site": "same-site", "Pragma": "no-cache", "Cache-Control": "no-cache" } json_body = { "device": { "deviceId": FAKE_DEVICE_ID, "width": 1920, "height": 1080, "type": "WEB", "name": "Windows Mozilla Firefox 97" }, "deviceId": FAKE_DEVICE_ID } resp = urlquick.post(URL_TV5MONDEPLUS_AUTH_ANONYMOUS_API, json=json_body, headers=headers_auth) json_parser = resp.json() headers = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:97.0) Gecko/20100101 Firefox/97.0", "Accept": "application/json, text/plain, */*", "Accept-Language": "fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3", 'authorization': 'Bearer %s' % json_parser["sessionToken"], "Sec-Fetch-Dest": "empty", "Sec-Fetch-Mode": "cors", "Sec-Fetch-Site": "same-site", "Pragma": "no-cache", "Cache-Control": "no-cache", "referrer": "https://www.tv5mondeplus.com/" } params = { "ifa": FAKE_DEVICE_ID, "deviceType": "Desktop", "width": "1920", "height": "1080", "pageUrl": "https%3A%2F%2Fwww.tv5mondeplus.com%2Fplayer%2F" + video_id, "domain": "www.tv5mondeplus.com", "mute": "false", "autoplay": "true" } resp2 = urlquick.get(URL_STREAM_DATA % video_id, params=params, headers=headers) json_parser2 = resp2.json() item = Listitem() item.path = json_parser2["formats"][0]["mediaLocator"] item.property[INPUTSTREAM_PROP] = 'inputstream.adaptive' item.property['inputstream.adaptive.manifest_type'] = 'mpd' item.property['inputstream.adaptive.license_type'] = 'com.widevine.alpha' header_license = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:97.0) Gecko/20100101 Firefox/97.0", "Accept": "*/*", "Accept-Language": "fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3", "Sec-Fetch-Dest": "empty", "Sec-Fetch-Mode": "cors", "Sec-Fetch-Site": "same-site", "Pragma": "no-cache", "Cache-Control": "no-cache", "referrer": "https://www.tv5mondeplus.com/" } license_server_url = json_parser2["formats"][0]["drm"][ "com.widevine.alpha"]["licenseServerUrl"] item.property['inputstream.adaptive.license_key'] = '%s|%s|R{SSM}|' \ % (license_server_url, urlencode(header_license)) item.label = get_selected_item_label() item.art.update(get_selected_item_art()) item.info.update(get_selected_item_info()) return item
def get_video_url(plugin, item_id, next_url, download_mode=False, **kwargs): resp = urlquick.get(next_url, headers={'User-Agent': web_utils.get_random_ua()}, max_age=-1) json_parser = json.loads(resp.text) if json_parser["detail"]["informations"]['consumptionPlatform'] == 'HAPI': # Get DeviceId header_device_id = { 'referer': 'https://secure-player.canal-plus.com/one/prod/v2/', } resp_device_id = urlquick.get(URL_DEVICE_ID, headers=header_device_id, max_age=-1) device_id = re.compile(r'deviceId\"\:\"(.*?)\"').findall( resp_device_id.text)[0] if xbmc.getCondVisibility('system.platform.android'): if get_kodi_version() < 18: xbmcgui.Dialog().ok('Info', plugin.localize(30602)) return False is_helper = inputstreamhelper.Helper('mpd') if not is_helper.check_inputstream(): return False if download_mode: xbmcgui.Dialog().ok('Info', plugin.localize(30603)) return False Script.notify("INFO", plugin.localize(LABELS['drm_notification']), Script.NOTIFY_INFO) return False # Get Portail Id session_requests = requests.session() resp_app_config = session_requests.get(URL_REPLAY % item_id) json_app_config = re.compile('window.app_config=(.*?)};').findall( resp_app_config.text)[0] json_app_config_parser = json.loads(json_app_config + ('}')) portail_id = json_app_config_parser["api"]["pass"][ "portailIdEncrypted"] # Get PassToken payload = { 'deviceId': 'unknown', 'vect': 'INTERNET', 'media': 'PC', 'portailId': portail_id } resp_token_mycanal = session_requests.post(URL_TOKEN, data=payload) json_token_parser = json.loads(resp_token_mycanal.text) pass_token = json_token_parser["response"]["passToken"] # Get stream Id for stream_datas in json_parser["detail"]["informations"][ "videoURLs"]: if stream_datas["drmType"] == "DRM PlayReady": payload = { 'comMode': stream_datas['comMode'], 'contentId': stream_datas['contentId'], 'distMode': stream_datas['distMode'], 'distTechnology': stream_datas['distTechnology'], 'drmType': stream_datas['drmType'], 'functionalType': stream_datas['functionalType'], 'hash': stream_datas['hash'], 'idKey': stream_datas['idKey'], 'quality': stream_datas['quality'] } payload = json.dumps(payload) headers = { 'Accept': 'application/json, text/plain, */*', 'Authorization': 'PASS Token="%s"' % pass_token, 'Content-Type': 'application/json; charset=UTF-8', 'XX-DEVICE': 'pc %s' % device_id, 'XX-DOMAIN': 'cpfra', 'XX-OPERATOR': 'pc', 'XX-Profile-Id': '0', 'XX-SERVICE': 'mycanal', 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 Safari/537.36' } resp_stream_datas = session_requests.put(URL_STREAM_DATAS, data=payload, headers=headers) jsonparser_stream_datas = json.loads( resp_stream_datas.text) resp_real_stream_datas = session_requests.get( jsonparser_stream_datas['@medias'], headers=headers) jsonparser_real_stream_datas = json.loads( resp_real_stream_datas.text) item = Listitem() item.path = jsonparser_real_stream_datas["VF"][0]["media"][ 0]["distribURL"] + '/manifest' item.label = get_selected_item_label() item.art.update(get_selected_item_art()) item.info.update(get_selected_item_info()) item.property['inputstreamaddon'] = 'inputstream.adaptive' item.property['inputstream.adaptive.manifest_type'] = 'ism' item.property[ 'inputstream.adaptive.license_type'] = 'com.microsoft.playready' return item else: if get_kodi_version() < 18: xbmcgui.Dialog().ok('Info', plugin.localize(30602)) return False is_helper = inputstreamhelper.Helper('mpd', drm='widevine') if not is_helper.check_inputstream(): return False if download_mode: xbmcgui.Dialog().ok('Info', plugin.localize(30603)) return False Script.notify("INFO", plugin.localize(LABELS['drm_notification']), Script.NOTIFY_INFO) return False # Get Portail Id session_requests = requests.session() resp_app_config = session_requests.get(URL_REPLAY % item_id) json_app_config = re.compile('window.app_config=(.*?)};').findall( resp_app_config.text)[0] json_app_config_parser = json.loads(json_app_config + ('}')) portail_id = json_app_config_parser["api"]["pass"][ "portailIdEncrypted"] # Get PassToken payload = { 'deviceId': 'unknown', 'vect': 'INTERNET', 'media': 'PC', 'portailId': portail_id } resp_token_mycanal = session_requests.post(URL_TOKEN, data=payload) json_token_parser = json.loads(resp_token_mycanal.text) pass_token = json_token_parser["response"]["passToken"] # Get stream Id for stream_datas in json_parser["detail"]["informations"][ "videoURLs"]: if 'Widevine' in stream_datas["drmType"]: payload = { 'comMode': stream_datas['comMode'], 'contentId': stream_datas['contentId'], 'distMode': stream_datas['distMode'], 'distTechnology': stream_datas['distTechnology'], 'drmType': stream_datas['drmType'], 'functionalType': stream_datas['functionalType'], 'hash': stream_datas['hash'], 'idKey': stream_datas['idKey'], 'quality': stream_datas['quality'] } payload = json.dumps(payload) headers = { 'Accept': 'application/json, text/plain, */*', 'Authorization': 'PASS Token="%s"' % pass_token, 'Content-Type': 'application/json; charset=UTF-8', 'XX-DEVICE': 'pc %s' % device_id, 'XX-DOMAIN': 'cpfra', 'XX-OPERATOR': 'pc', 'XX-Profile-Id': '0', 'XX-SERVICE': 'mycanal', 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 Safari/537.36' } resp_stream_datas = session_requests.put(URL_STREAM_DATAS, data=payload, headers=headers) jsonparser_stream_datas = json.loads( resp_stream_datas.text) resp_real_stream_datas = session_requests.get( jsonparser_stream_datas['@medias'], headers=headers) jsonparser_real_stream_datas = json.loads( resp_real_stream_datas.text) item = Listitem() item.path = jsonparser_real_stream_datas["VF"][0]["media"][ 0]["distribURL"] + '/manifest' item.label = get_selected_item_label() item.art.update(get_selected_item_art()) item.info.update(get_selected_item_info()) item.property['inputstreamaddon'] = 'inputstream.adaptive' item.property['inputstream.adaptive.manifest_type'] = 'ism' item.property[ 'inputstream.adaptive.license_type'] = 'com.widevine.alpha' value_pass_token = 'PASS Token="%s"' % pass_token headers2 = { 'Accept': 'application/json, text/plain, */*', 'Authorization': value_pass_token, 'Content-Type': 'text/plain', 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 Safari/537.36', 'Origin': 'https://www.mycanal.fr', 'XX-DEVICE': 'pc %s' % device_id, 'XX-DOMAIN': 'cpfra', 'XX-OPERATOR': 'pc', 'XX-Profile-Id': '0', 'XX-SERVICE': 'mycanal', } # Return HTTP 200 but the response is not correctly interpreted by inputstream (https://github.com/peak3d/inputstream.adaptive/issues/267) item.property[ 'inputstream.adaptive.license_key'] = jsonparser_stream_datas[ '@licence'] + '?drmType=DRM%20Widevine' + '|%s|b{SSM}|' % urlencode( headers2) return item stream_url = '' for stream_datas in json_parser["detail"]["informations"]["videoURLs"]: if stream_datas["encryption"] == 'clear': stream_url = stream_datas["videoURL"] if download_mode: return download.download_video(stream_url) return stream_url
def get_live_url(plugin, item_id, **kwargs): if get_kodi_version() < 18: xbmcgui.Dialog().ok('Info', plugin.localize(30602)) return False is_helper = inputstreamhelper.Helper('mpd', drm='widevine') if not is_helper.check_inputstream(): return False headers = {'X-Requested-With': 'XMLHttpRequest'} resp_token = urlquick.get(URL_TOKEN_API, headers=headers, max_age=-1) session_token = resp_token.cookies['npo_session'] json_parser_token = json.loads(resp_token.text) api_token = json_parser_token['token'] resp = urlquick.get(URL_LIVE_ID % item_id, max_age=-1) video_id = '' list_media_id = re.compile(r'media-id\=\"(.*?)\"').findall(resp.text) for media_id in list_media_id: if 'LI_' in media_id: video_id = media_id # Build PAYLOAD payload = {"_token": api_token} cookies = {"npo_session": session_token} resp2 = urlquick.post(URL_TOKEN_ID % video_id, cookies=cookies, data=payload, max_age=-1) json_parser = json.loads(resp2.text) token_id = json_parser['token'] resp3 = urlquick.get(URL_STREAM % (video_id, token_id), max_age=-1) json_parser2 = json.loads(resp3.text) if "html" in json_parser2 and "Vanwege uitzendrechten is het niet mogelijk om deze uitzending buiten Nederland te bekijken." in json_parser2[ "html"]: plugin.notify('ERROR', plugin.localize(30713)) return False licence_url = json_parser2["stream"]["keySystemOptions"][0]["options"][ "licenseUrl"] licence_url_header = json_parser2["stream"]["keySystemOptions"][0][ "options"]["httpRequestHeaders"] xcdata_value = licence_url_header["x-custom-data"] item = Listitem() item.path = json_parser2["stream"]["src"] item.label = get_selected_item_label() item.art.update(get_selected_item_art()) item.info.update(get_selected_item_info()) if plugin.setting.get_boolean('active_subtitle'): item.subtitles.append(URL_SUBTITLE % video_id) item.property[INPUTSTREAM_PROP] = 'inputstream.adaptive' item.property['inputstream.adaptive.manifest_type'] = 'mpd' item.property['inputstream.adaptive.license_type'] = 'com.widevine.alpha' item.property['inputstream.adaptive.manifest_update_parameter'] = 'full' item.property[ 'inputstream.adaptive.license_key'] = licence_url + '|Content-Type=&User-Agent=Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3041.0 Safari/537.36&x-custom-data=%s|R{SSM}|' % xcdata_value return item
def get_video_url(plugin, item_id, next_url, download_mode=False, **kwargs): if 'www.mycanal.fr' in next_url: if get_kodi_version() < 18: xbmcgui.Dialog().ok('Info', plugin.localize(30602)) return False is_helper = inputstreamhelper.Helper('mpd', drm='widevine') if not is_helper.check_inputstream(): return False if download_mode: xbmcgui.Dialog().ok('Info', plugin.localize(30603)) return False # Get DeviceId header_device_id = { 'referer': 'https://secure-player.canal-plus.com/one/prod/v2/', } resp_device_id = urlquick.get(URL_DEVICE_ID, headers=header_device_id, max_age=-1) device_id = re.compile( r'deviceId\"\:\"(.*?)\"').findall(resp_device_id.text)[0] # Get Portail Id session_requests = requests.session() resp_app_config = session_requests.get(URL_REPLAY % item_id) json_app_config = re.compile('window.app_config=(.*?)};').findall( resp_app_config.text)[0] json_app_config_parser = json.loads(json_app_config + ('}')) portail_id = json_app_config_parser["api"]["pass"][ "portailIdEncrypted"] # Get PassToken payload = { 'deviceId': 'unknown', 'vect': 'INTERNET', 'media': 'PC', 'portailId': portail_id } resp_token_mycanal = session_requests.post(URL_TOKEN, data=payload) json_token_parser = json.loads(resp_token_mycanal.text) pass_token = json_token_parser["response"]["passToken"] video_id = next_url.split('/')[-1] headers = { 'Accept': 'application/json, text/plain, */*', 'Authorization': 'PASS Token="%s"' % pass_token, 'Content-Type': 'application/json; charset=UTF-8', 'XX-DEVICE': 'pc %s' % device_id, 'XX-DOMAIN': 'cpfra', 'XX-OPERATOR': 'pc', 'XX-Profile-Id': '0', 'XX-SERVICE': 'mycanal', 'User-Agent': web_utils.get_random_ua() } value_datas_json = session_requests.get(URL_VIDEO_DATAS % video_id, headers=headers) value_datas_jsonparser = json.loads(value_datas_json.text) comMode_value = '' contentId_value = '' distMode_value = '' distTechnology_value = '' drmType_value = '' functionalType_value = '' hash_value = '' idKey_value = '' quality_value = '' if 'available' not in value_datas_jsonparser: return False for stream_datas in value_datas_jsonparser["available"]: if 'Widevine' in stream_datas["drmType"]: comMode_value = stream_datas['comMode'] contentId_value = stream_datas['contentId'] distMode_value = stream_datas['distMode'] distTechnology_value = stream_datas['distTechnology'] drmType_value = stream_datas['drmType'] functionalType_value = stream_datas['functionalType'] hash_value = stream_datas['hash'] idKey_value = stream_datas['idKey'] quality_value = stream_datas['quality'] payload = { 'comMode': comMode_value, 'contentId': contentId_value, 'distMode': distMode_value, 'distTechnology': distTechnology_value, 'drmType': drmType_value, 'functionalType': functionalType_value, 'hash': hash_value, 'idKey': idKey_value, 'quality': quality_value } payload = json.dumps(payload) headers = { 'Accept': 'application/json, text/plain, */*', 'Authorization': 'PASS Token="%s"' % pass_token, 'Content-Type': 'application/json; charset=UTF-8', 'XX-DEVICE': 'pc %s' % device_id, 'XX-DOMAIN': 'cpfra', 'XX-OPERATOR': 'pc', 'XX-Profile-Id': '0', 'XX-SERVICE': 'mycanal', 'User-Agent': web_utils.get_random_ua() } resp_stream_datas = session_requests.put( URL_STREAM_DATAS, data=payload, headers=headers) jsonparser_stream_datas = json.loads(resp_stream_datas.text) resp_real_stream_datas = session_requests.get( jsonparser_stream_datas['@medias'], headers=headers) jsonparser_real_stream_datas = json.loads( resp_real_stream_datas.text) item = Listitem() item.path = jsonparser_real_stream_datas["VF"][0]["media"][0]["distribURL"] + '/manifest' item.label = get_selected_item_label() item.art.update(get_selected_item_art()) item.info.update(get_selected_item_info()) item.property['inputstreamaddon'] = 'inputstream.adaptive' item.property['inputstream.adaptive.manifest_type'] = 'ism' item.property[ 'inputstream.adaptive.license_type'] = 'com.widevine.alpha' value_pass_token = 'PASS Token="%s"' % pass_token headers2 = { 'Accept': 'application/json, text/plain, */*', 'Authorization': value_pass_token, 'Content-Type': 'text/plain', 'User-Agent': web_utils.get_random_ua(), 'Origin': 'https://www.mycanal.fr', 'XX-DEVICE': 'pc %s' % device_id, 'XX-DOMAIN': 'cpfra', 'XX-OPERATOR': 'pc', 'XX-Profile-Id': '0', 'XX-SERVICE': 'mycanal', } # Return HTTP 200 but the response is not correctly interpreted by inputstream (https://github.com/peak3d/inputstream.adaptive/issues/267) item.property['inputstream.adaptive.license_key'] = jsonparser_stream_datas['@licence'] + '?drmType=DRM%20Widevine' + '|%s|R{SSM}|' % urlencode(headers2) # return item Script.notify("INFO", plugin.localize(30702), Script.NOTIFY_INFO) return False else: resp = urlquick.get( next_url, headers={'User-Agent': web_utils.get_random_ua()}, max_age=-1) json_parser = json.loads(resp.text) return json_parser["detail"]["informations"]["playsets"]["available"][0]["videoURL"]
def get_live_url(plugin, item_id, **kwargs): if get_kodi_version() < 18: xbmcgui.Dialog().ok('Info', plugin.localize(30602)) return False resp_js_id = urlquick.get(URL_GET_JS_ID_API_KEY) js_id = re.compile(r'client\-(.*?)\.bundle\.js').findall( resp_js_id.text)[0] resp = urlquick.get(URL_API_KEY % js_id) # Hack to force encoding of the response resp.encoding = 'utf-8' api_key = re.compile(r'login.rtl.be\"\,key\:\"(.*?)\"').findall( resp.text)[0] if plugin.setting.get_string('rtlplaybe.login') == '' or\ plugin.setting.get_string('rtlplaybe.password') == '': xbmcgui.Dialog().ok( plugin.localize(30600), plugin.localize(30604) % ('RTLPlay (BE)', 'https://www.rtlplay.be')) return False # Build PAYLOAD payload = { "loginID": plugin.setting.get_string('rtlplaybe.login'), "password": plugin.setting.get_string('rtlplaybe.password'), "apiKey": api_key, "format": "jsonp", "callback": "gigya.callback" } # LOGIN resp2 = urlquick.post(URL_COMPTE_LOGIN, data=payload, headers={ 'User-Agent': web_utils.get_random_ua(), 'referer': 'https://www.rtlplay.be/connexion' }) json_parser = json.loads( resp2.text.replace('gigya.callback(', '').replace(');', '')) if "UID" not in json_parser: plugin.notify('ERROR', 'RTLPlay (BE) : ' + plugin.localize(30711)) return False account_id = json_parser["UID"] account_timestamp = json_parser["signatureTimestamp"] account_signature = json_parser["UIDSignature"] is_helper = inputstreamhelper.Helper('mpd', drm='widevine') if not is_helper.check_inputstream(): return False # Build PAYLOAD headers payload_headers = { 'x-auth-gigya-signature': account_signature, 'x-auth-gigya-signature-timestamp': account_timestamp, 'x-auth-gigya-uid': account_id, 'User-Agent': web_utils.get_random_ua(), 'x-customer-name': 'rtlbe' } channel = 'rtlbe_' + item_id token_json = urlquick.get(URL_TOKEN_DRM % (account_id, 'dashcenc_%s' % channel), headers=payload_headers, max_age=-1) token_jsonparser = json.loads(token_json.text) token = token_jsonparser["token"] video_json = urlquick.get(URL_LIVE_JSON % channel, headers={ 'User-Agent': web_utils.get_random_ua(), 'x-customer-name': 'rtlbe' }, max_age=-1) json_parser = json.loads(video_json.text) if not json_parser[channel]: plugin.notify('ERROR', plugin.localize(30712)) return False video_assets = json_parser[channel][0]['live']['assets'] if not video_assets: plugin.notify('INFO', plugin.localize(30716)) return False subtitle_url = '' if plugin.setting.get_boolean('active_subtitle'): for asset in video_assets: if 'subtitle_vtt' in asset["type"]: subtitle_url = asset['full_physical_path'] final_video_url = get_final_video_url(plugin, video_assets, 'delta_dashcenc_h264') if final_video_url is None: return False for asset in video_assets: if 'delta_dashcenc_h264' in asset["type"]: item = Listitem() item.path = final_video_url if 'http' in subtitle_url: item.subtitles.append(subtitle_url) item.property[INPUTSTREAM_PROP] = 'inputstream.adaptive' item.property['inputstream.adaptive.manifest_type'] = 'mpd' item.property[ 'inputstream.adaptive.license_type'] = 'com.widevine.alpha' item.property[ 'inputstream.adaptive.license_key'] = URL_LICENCE_KEY % token item.label = get_selected_item_label() item.art.update(get_selected_item_art()) item.info.update(get_selected_item_info()) return item return False
def list_videos_search(plugin, search_query, item_id, page, **kwargs): if search_query is None or len(search_query) == 0: return False json_body_template = """ { "requests": [ { "indexName": "rtlmutu_prod_bedrock_layout_items_v1_rtlbe_main", "query": "search_term", "params": "hitsPerPage=50&facetFilters=%5B%22metadata.item_type%3Afunctionality%22%5D" }, { "indexName": "rtlmutu_prod_bedrock_layout_items_v1_rtlbe_main", "query": "search_term", "params": "hitsPerPage=50&facetFilters=%5B%22metadata.item_type%3Aplaylist%22%5D" }, { "indexName": "rtlmutu_prod_bedrock_layout_items_v1_rtlbe_main", "query": "search_term", "params": "hitsPerPage=50&facetFilters=%5B%22metadata.item_type%3Aprogram%22%5D" }, { "indexName": "rtlmutu_prod_bedrock_layout_items_v1_rtlbe_main", "query": "search_term", "params": "hitsPerPage=50&facetFilters=%5B%22metadata.item_type%3Avc%22%5D" }, { "indexName": "rtlmutu_prod_bedrock_layout_items_v1_rtlbe_main", "query": "search_term", "params": "hitsPerPage=50&facetFilters=%5B%22metadata.item_type%3Avi%22%5D" } ] } """ json_body = json.loads(json_body_template) for request in json_body['requests']: request['query'] = search_query headers = { 'User-Agent': web_utils.get_random_ua(), 'Accept': '*/*', 'Accept-Language': 'fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3', 'Accept-Encoding': 'gzip, deflate, br', 'Content-Type': 'application/x-www-form-urlencoded', 'x-algolia-api-key': '5fce02cb376fb2cda773be8a8404598a', 'x-algolia-application-id': 'NHACVIVXXK', 'Origin': 'https://www.rtlplay.be', 'DNT': '1', 'Sec-Fetch-Dest': 'empty', 'Sec-Fetch-Mode': 'cors', 'Sec-Fetch-Site': 'cross-site', 'Referer': 'https://www.rtlplay.be/', 'Connection': 'keep-alive' } resp = urlquick.post(URL_SEARCH, None, json_body, headers=headers) json_parser = resp.json() for result in json_parser["results"]: if result["nbHits"] > 0: for hit in result["hits"]: search_title = hit["item"]["itemContent"]["title"] search_id = hit["item"]["itemContent"]["action"]["target"][ "value_layout"]["id"] search_type = hit["item"]["itemContent"]["action"]["target"][ "value_layout"]["type"] # search_image = result["data"]["images"]["illustration"]["16x9"]["1248x702"] if search_type == "program": item = Listitem() item.label = search_title # item.art['thumb'] = item.art['landscape'] = search_image item.set_callback(list_program_categories, item_id=item_id, program_id=search_id) item_post_treatment(item) yield item else: is_downloadable = False if get_kodi_version() < 18: is_downloadable = True if search_type != 'playlist': item = Listitem() item.label = search_title # populate_item(item, video['clips'][0]) item.set_callback(get_video_url, item_id=item_id, video_id=search_id) # TODO playlist # else: # item = Listitem() # item.label = search_title # # populate_item(item, video) # item.set_callback(get_playlist_urls, # item_id=item_id, # video_id=search_id, # url=url) item_post_treatment(item, is_playable=True, is_downloadable=is_downloadable) yield item
def get_video_url(plugin, item_id, video_id, download_mode=False, **kwargs): if get_kodi_version() < 18: xbmcgui.Dialog().ok('Info', plugin.localize(30602)) return False is_helper = inputstreamhelper.Helper('mpd', drm='widevine') if not is_helper.check_inputstream(): return False # Get info_poste ? info_poste = { 'height': 1080, 'width': 1920, 'model': 'Netscape', 'name': 'Gecko', 'os': 'Linux x86_64', 'osVersion': '5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36","manufacturer":"Google Inc.', 'type': 'WEB' } # Get DeviveId ? payload = { 'deviceId': 'WEB_450118664537368504183835373631080192024', 'device': info_poste, 'rememberMe': False, 'username': '', 'password': '' } resp = urlquick.post(URL_TV5MONDEPLUS_AUTH_ANONYMOUS_API, json=payload) json_parser = json.loads(resp.text) headers = { 'authorization': 'Bearer %s' % json_parser["sessionToken"], } resp2 = urlquick.get(URL_STREAM_DATAS % video_id, headers=headers) json_parser2 = json.loads(resp2.text) item = Listitem() item.path = json_parser2["formats"][0]["mediaLocator"] item.property['inputstreamaddon'] = 'inputstream.adaptive' item.property['inputstream.adaptive.manifest_type'] = 'mpd' item.property[ 'inputstream.adaptive.license_type'] = 'com.widevine.alpha' # Get Licence Key HTTP 500 - {"code":100000,"message":"An error has occurred. See logs for details."} headers2 = { 'authorization': 'Bearer %s' % json_parser2["playToken"], 'referer': 'https://www.tv5mondeplus.com/', 'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36', 'origin': 'https://www.tv5mondeplus.com', 'accept': '*/*', 'accept-encoding': 'gzip, deflate, br', 'accept-language': 'en-US,en;q=0.9', 'sec-fetch-dest': 'empty', 'sec-fetch-mode': 'cors', 'sec-fetch-site': 'cross-site' } item.property[ 'inputstream.adaptive.license_key'] = '%s|%s|R{SSM}|' % ( json_parser2["formats"][0]["drm"]["com.widevine.alpha"]["licenseServerUrl"], urlencode(headers2)) item.label = get_selected_item_label() item.art.update(get_selected_item_art()) item.info.update(get_selected_item_info()) return item
def get_live_url(plugin, item_id, video_id, **kwargs): if item_id == 'fun_radio' or \ item_id == 'rtl2' or \ item_id == 'mb': if item_id == 'mb': video_json = urlquick.get( URL_LIVE_JSON % (item_id.upper()), headers={'User-Agent': web_utils.get_random_ua()}, max_age=-1) json_parser = json.loads(video_json.text) video_assets = json_parser[item_id.upper()][0]['live']['assets'] else: video_json = urlquick.get( URL_LIVE_JSON % (item_id), headers={'User-Agent': web_utils.get_random_ua()}, max_age=-1) json_parser = json.loads(video_json.text) video_assets = json_parser[item_id][0]['live']['assets'] if not video_assets: plugin.notify('INFO', plugin.localize(30716)) return False subtitle_url = '' if plugin.setting.get_boolean('active_subtitle'): for asset in video_assets: if 'subtitle_vtt' in asset["type"]: subtitle_url = asset['full_physical_path'] for asset in video_assets: if 'delta_hls_h264' in asset["type"]: item = Listitem() item.path = asset['full_physical_path'] if 'http' in subtitle_url: item.subtitles.append(subtitle_url) item.label = get_selected_item_label() item.art.update(get_selected_item_art()) item.info.update(get_selected_item_info()) return item return False else: if get_kodi_version() < 18: xbmcgui.Dialog().ok('Info', plugin.localize(30602)) return False resp_js_id = urlquick.get(URL_GET_JS_ID_API_KEY) js_id = re.compile(r'client\-(.*?)\.bundle\.js').findall( resp_js_id.text)[0] resp = urlquick.get(URL_API_KEY % js_id) api_key = re.compile(r'\"eu1.gigya.com\"\,key\:\"(.*?)\"').findall( resp.text)[0] if plugin.setting.get_string('6play.login') == '' or\ plugin.setting.get_string('6play.password') == '': xbmcgui.Dialog().ok( 'Info', plugin.localize(30604) % ('6play', 'https://www.6play.fr')) return False # Build PAYLOAD payload = { "loginID": plugin.setting.get_string('6play.login'), "password": plugin.setting.get_string('6play.password'), "apiKey": api_key, "format": "jsonp", "callback": "jsonp_3bbusffr388pem4" } # LOGIN resp2 = urlquick.post(URL_COMPTE_LOGIN, data=payload, headers={ 'User-Agent': web_utils.get_random_ua(), 'referer': 'https://www.6play.fr/connexion' }) json_parser = json.loads( resp2.text.replace('jsonp_3bbusffr388pem4(', '').replace(');', '')) if "UID" not in json_parser: plugin.notify('ERROR', '6play : ' + plugin.localize(30711)) return False account_id = json_parser["UID"] account_timestamp = json_parser["signatureTimestamp"] account_signature = json_parser["UIDSignature"] is_helper = inputstreamhelper.Helper('mpd', drm='widevine') if not is_helper.check_inputstream(): return False # Build PAYLOAD headers payload_headers = { 'x-auth-gigya-signature': account_signature, 'x-auth-gigya-signature-timestamp': account_timestamp, 'x-auth-gigya-uid': account_id, 'x-customer-name': 'm6web' } if item_id == '6ter': token_json = urlquick.get(URL_TOKEN_DRM % (account_id, 'dashcenc_%s' % '6T'), headers=payload_headers, max_age=-1) else: token_json = urlquick.get( URL_TOKEN_DRM % (account_id, 'dashcenc_%s' % item_id.upper()), headers=payload_headers, max_age=-1) token_jsonparser = json.loads(token_json.text) token = token_jsonparser["token"] if item_id == '6ter': video_json = urlquick.get( URL_LIVE_JSON % '6T', headers={'User-Agent': web_utils.get_random_ua()}, max_age=-1) json_parser = json.loads(video_json.text) video_assets = json_parser['6T'][0]['live']['assets'] else: video_json = urlquick.get( URL_LIVE_JSON % (item_id.upper()), headers={'User-Agent': web_utils.get_random_ua()}, max_age=-1) json_parser = json.loads(video_json.text) video_assets = json_parser[item_id.upper()][0]['live']['assets'] if not video_assets: plugin.notify('INFO', plugin.localize(30716)) return False subtitle_url = '' if plugin.setting.get_boolean('active_subtitle'): for asset in video_assets: if 'subtitle_vtt' in asset["type"]: subtitle_url = asset['full_physical_path'] for asset in video_assets: if 'delta_dashcenc_h264' in asset["type"]: item = Listitem() item.path = asset['full_physical_path'] if 'http' in subtitle_url: item.subtitles.append(subtitle_url) item.property['inputstreamaddon'] = 'inputstream.adaptive' item.property['inputstream.adaptive.manifest_type'] = 'mpd' item.property[ 'inputstream.adaptive.license_type'] = 'com.widevine.alpha' item.property[ 'inputstream.adaptive.license_key'] = URL_LICENCE_KEY % token item.label = get_selected_item_label() item.art.update(get_selected_item_art()) item.info.update(get_selected_item_info()) return item return False
def get_video_url(plugin, item_id, video_id, download_mode=False, **kwargs): video_format = 'hls' url_json = URL_VIDEO_STREAM % (video_id, video_format) htlm_json = urlquick.get(url_json, headers={'User-Agent': web_utils.get_random_ua()}, max_age=-1) json_parser = json.loads(htlm_json.text) if json_parser['code'] >= 400: plugin.notify('ERROR', plugin.localize(30716)) return False # Check DRM in the m3u8 file manifest = urlquick.get(json_parser["url"], headers={ 'User-Agent': web_utils.get_random_ua()}, max_age=-1).text if 'drm' in manifest: if get_kodi_version() < 18: xbmcgui.Dialog().ok('Info', plugin.localize(30602)) return False else: video_format = 'dash' if video_format == 'hls': final_video_url = json_parser["url"].replace('2800000', '4000000') if download_mode: return download.download_video(final_video_url) return final_video_url else: if download_mode: xbmcgui.Dialog().ok('Info', plugin.localize(30603)) return False url_json = URL_VIDEO_STREAM % (video_id, video_format) htlm_json = urlquick.get( url_json, headers={'User-Agent': web_utils.get_random_ua()}, max_age=-1) json_parser = json.loads(htlm_json.text) is_helper = inputstreamhelper.Helper('mpd', drm='widevine') if not is_helper.check_inputstream(): return False item = Listitem() item.path = json_parser["url"] item.label = get_selected_item_label() item.art.update(get_selected_item_art()) item.info.update(get_selected_item_info()) item.property['inputstreamaddon'] = 'inputstream.adaptive' item.property['inputstream.adaptive.manifest_type'] = 'mpd' item.property[ 'inputstream.adaptive.license_type'] = 'com.widevine.alpha' item.property[ 'inputstream.adaptive.license_key'] = URL_LICENCE_KEY % video_id return item