示例#1
0
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
示例#2
0
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):

    video_id = 'L_%s' % item_id.upper()
    url_json = URL_VIDEO_STREAM % video_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)

    if json_parser['delivery']['code'] > 400:
        plugin.notify('ERROR', plugin.localize(30713))
        return False
    else:
        is_helper = inputstreamhelper.Helper('mpd', drm='widevine')
        if not is_helper.check_inputstream():
            return False

        item = Listitem()
        item.path = json_parser['delivery']['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'] = URL_LICENCE_KEY % video_id

        return item
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
示例#5
0
def get_live_url(plugin, item_id, **kwargs):

    is_helper = inputstreamhelper.Helper('mpd')
    if not is_helper.check_inputstream():
        return False

    resp = urlquick.get(URL_LIVE,
                        headers={"User-Agent": web_utils.get_random_ua()},
                        max_age=-1)
    root = resp.parse()
    url_live_datas = URL_ROOT + root.find(".//div[@class='HDR_VISIO']").get(
        "data-url") + "&mode=html"

    resp2 = urlquick.get(url_live_datas,
                         headers={"User-Agent": web_utils.get_random_ua()},
                         max_age=-1)
    json_parser = json.loads(resp2.text)

    item = Listitem()
    item.path = json_parser["files"]["auto"]
    item.property["inputstreamaddon"] = "inputstream.adaptive"
    item.property["inputstream.adaptive.manifest_type"] = "mpd"
    item.label = get_selected_item_label()
    item.art.update(get_selected_item_art())
    item.info.update(get_selected_item_info())
    return item
示例#6
0
def get_video_url(plugin, item_id, video_slug, download_mode=False, **kwargs):

    is_helper = inputstreamhelper.Helper('mpd', drm='widevine')
    if not is_helper.check_inputstream():
        return False

    resp = urlquick.get(URL_INFO_STREAM % video_slug)
    data_account = re.compile(r'data-accound\=\"(.*?)\"').findall(resp.text)[0]
    data_player = re.compile(r'data-player\=\"(.*?)\"').findall(resp.text)[0]
    data_video_id = re.compile(r'data-video-id\=\"(.*?)\"').findall(
        resp.text)[0]

    # Method to get JSON from 'edge.api.brightcove.com'
    resp = urlquick.get(
        URL_BRIGHTCOVE_VIDEO_JSON % (data_account, data_video_id),
        headers={
            'User-Agent':
            web_utils.get_random_ua(),
            'Accept':
            'application/json;pk=%s' %
            (get_brightcove_policy_key(data_account, data_player)),
            'X-Forwarded-For':
            plugin.setting.get_string('header_x-forwarded-for')
        })
    json_parser = json.loads(resp.text)

    video_url = ''
    licence_url = ''
    is_protected_drm = False
    if 'sources' in json_parser:
        for url in json_parser["sources"]:
            if 'src' in url:
                if 'manifest.mpd' in url["src"]:
                    video_url = url["src"]
                    if 'key_systems' in url:
                        licence_url = url['key_systems']['com.widevine.alpha'][
                            'license_url']
                        is_protected_drm = True
    else:
        if json_parser[0]['error_code'] == "ACCESS_DENIED":
            plugin.notify('ERROR', plugin.localize(30713))
            return False

    if video_url == '':
        return False

    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'
    if is_protected_drm:
        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|R{SSM}|'
    return item
def get_video_url(plugin,
                  item_id,
                  video_url,
                  download_mode=False,
                  **kwargs):

    is_helper = inputstreamhelper.Helper('mpd', drm='widevine')
    if not is_helper.check_inputstream():
        return False

    resp = urlquick.get(video_url,
                        headers={'User-Agent': web_utils.get_random_ua()},
                        max_age=-1)
    stream_datas = resp.text.split('addPlayer(')[1].split(');')[0].replace(
        "\n", "").replace("\r", "").split(',')
    data_account = stream_datas[0].strip().replace("'", "")
    data_player = stream_datas[1].strip().replace("'", "")
    if item_id == 'tx':
        data_video_id = stream_datas[4].strip().replace("'", "")
    else:
        data_video_id = 'ref:' + stream_datas[4].strip().replace("'", "")

    # Method to get JSON from 'edge.api.brightcove.com'
    resp = urlquick.get(
        URL_BRIGHTCOVE_VIDEO_JSON % (data_account, data_video_id),
        headers={
            'User-Agent':
            web_utils.get_random_ua(),
            'Accept':
            'application/json;pk=%s' %
            (get_brightcove_policy_key(data_account, data_player)),
            'X-Forwarded-For':
            plugin.setting.get_string('header_x-forwarded-for')
        })
    json_parser = json.loads(resp.text)

    video_url = ''
    if 'sources' in json_parser:
        for url in json_parser["sources"]:
            if 'src' in url:
                if 'manifest.mpd' in url["src"]:
                    video_url = url["src"]
    else:
        if json_parser[0]['error_code'] == "ACCESS_DENIED":
            plugin.notify('ERROR', plugin.localize(30713))
            return False

    if video_url == '':
        return False

    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'
    return item
示例#8
0
def video(plugin, path, title, **kwargs):
    """Menu of the app with v1 API."""
    headers = {
        'User-Agent': USER_AGENT,
        'Content-type': 'application/json',
        'Accept': 'application/json, text/plain, */*',
    }

    url = API_CDN_ROOT + path

    params = {
        "app": "bfmrmc",
        "device": "browser",
        "token": token,
        "universe": "provider",
    }

    resp = urlquick.get(url, params=params, headers=headers).json()

    # For reuse params dict.
    del params["universe"]

    for stream in resp[0]["offers"][0]["streams"]:
        if stream["drm"] == "WIDEVINE":
            data = {
                "app": "bfmrmc",
                "device": "browser",
                "macAddress": "PC",
                "offerId": resp[0]["offers"][0]["offerId"],
                "token": token,
            }
            # Needed ID for the customdata.
            entitlementId = urlquick.post(
                "https://ws-backendtv.rmcbfmplay.com/gaia-core/rest/api/web/v1/replay/play",
                params=params,
                headers=headers,
                json=data,
            ).json()["entitlementId"]

            item = Listitem()
            item.label = get_selected_item_label()
            item.art.update(get_selected_item_art())
            item.info.update(get_selected_item_info())
            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"
            customdata = "description={}&deviceId=byPassARTHIUS&deviceName=Firefox-96.0----Windows&deviceType=PC&osName=Windows&osVersion=10&persistent=false&resolution=1600x900&tokenType=castoken&tokenSSO={}&entitlementId={}&type=LIVEOTT&accountId={}".format(
                USER_AGENT, token, entitlementId, account_id)

            customdata = urllib.parse.quote(customdata)
            item.property["inputstream.adaptive.license_key"] = (
                "https://ws-backendtv.rmcbfmplay.com/asgard-drm-widevine/public/licence|User-Agent="
                + USER_AGENT + "&customdata=" + customdata +
                "&Origin=https://www.rmcbfmplay.com&Content-Type=" +
                "|R{SSM}|")
            return item
def get_video_url(plugin,
                  item_id,
                  program_id,
                  download_mode=False,
                  **kwargs):

    if 'www.wat.tv/embedframe' in program_id:
        url = 'http:' + program_id
    elif "http" not in program_id:
        if program_id[0] == '/':
            program_id = program_id[1:]
        url = URL_ROOT(program_id)
    else:
        url = program_id

    video_html = urlquick.get(url).text

    if 'www.wat.tv/embedframe' in program_id:
        video_id = re.compile('UVID=(.*?)&').findall(video_html)[0]
    elif item_id == 'lci':
        video_id = re.compile(r'data-videoid="(.*?)"').findall(video_html)[0]
    else:
        root = video_html.parse()
        iframe_player = root.find(".//div[@class='iframe_player']")
        if iframe_player is not None:
            video_id = iframe_player.get('data-watid')
        else:
            video_id = re.compile(
                r'www\.tf1\.fr\/embedplayer\/(.*?)\"').findall(video_html)[0]

    url_json = URL_VIDEO_STREAM % video_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)

    if download_mode:
        xbmcgui.Dialog().ok('Info', plugin.localize(30603))
        return False

    is_helper = inputstreamhelper.Helper('mpd', drm='widevine')
    if not is_helper.check_inputstream():
        return False

    item = Listitem()
    item.path = json_parser["mpd"]
    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'] = URL_LICENCE_KEY % video_id

    return item
示例#10
0
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_francetv_video_stream(plugin, id_diffusion, download_mode=False):

    geoip_value = web_utils.geoip()
    if not geoip_value:
        geoip_value = 'FR'
    resp = urlquick.get(URL_FRANCETV_CATCHUP_PROGRAM_INFO %
                        (id_diffusion, geoip_value),
                        max_age=-1)
    json_parser = json.loads(resp.text)

    if 'video' not in json_parser:
        plugin.notify('ERROR', plugin.localize(30716))
        return False

    all_video_datas = []
    video_datas = json_parser['video']
    # Implementer Caption (found case)
    # Implement DRM (found case)
    if video_datas['drm'] is not None:
        all_video_datas.append(
            (video_datas['format'], 'True', video_datas['token']))
    else:
        all_video_datas.append(
            (video_datas['format'], 'False', video_datas['token']))

    url_selected = all_video_datas[0][2]
    if 'hls' in all_video_datas[0][0]:
        json_parser2 = json.loads(urlquick.get(url_selected, max_age=-1).text)
        final_video_url = json_parser2['url']
        if download_mode:
            return download.download_video(final_video_url)
        return final_video_url
    elif 'dash' in all_video_datas[0][0]:
        if download_mode:
            xbmcgui.Dialog().ok('Info', plugin.localize(30603))
            return False
        is_helper = inputstreamhelper.Helper('mpd')
        if not is_helper.check_inputstream():
            return False
        json_parser2 = json.loads(urlquick.get(url_selected, max_age=-1).text)
        item = Listitem()
        item.path = json_parser2['url']
        item.property['inputstreamaddon'] = 'inputstream.adaptive'
        item.property['inputstream.adaptive.manifest_type'] = 'mpd'
        item.label = get_selected_item_label()
        item.art.update(get_selected_item_art())
        item.info.update(get_selected_item_info())

        return item
    else:
        # Return info the format is not known
        return False
示例#12
0
文件: bvn.py 项目: akuala/repo.kuala
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
示例#13
0
def get_live_url(plugin, item_id, **kwargs):

    if item_id == 'BFM_régions':
        item_id = kwargs.get('language',
                             Script.setting['BFM_Régions.language'])
    headers = {
        'User-Agent': USER_AGENT,
        'Content-type': 'application/json',
        'Accept': 'application/json, text/plain, */*',
    }

    url = "https://ws-backendtv.rmcbfmplay.com/sekai-service-plan/public/v2/service-list"

    params = {
        "app": "bfmrmc",
        "device": "browser",
        "token": token,
    }

    resp = urlquick.get(url, params=params, headers=headers).json()

    for data in resp:
        if data["name"] == item_id:
            item = Listitem()
            item.label = get_selected_item_label()
            item.art.update(get_selected_item_art())
            item.info.update(get_selected_item_info())

            for stream in data["streams"]:
                if stream["drm"] == "WIDEVINE":

                    # Workaround for IA bug : https://github.com/xbmc/inputstream.adaptive/issues/804
                    response = urlquick.get(stream["url"])
                    item.path = re.search('<Location>([^<]+)</Location>',
                                          response.text).group(1).replace(
                                              ';', '&')

                    item.property[INPUTSTREAM_PROP] = "inputstream.adaptive"
                    item.property["inputstream.adaptive.manifest_type"] = "mpd"
                    item.property[
                        "inputstream.adaptive.license_type"] = "com.widevine.alpha"
                    customdata = "description={}&deviceId=byPassARTHIUS&deviceName=Firefox-96.0----Windows&deviceType=PC&osName=Windows&osVersion=10&persistent=false&resolution=1600x900&tokenType=castoken&tokenSSO={}&type=LIVEOTT&accountId={}".format(
                        USER_AGENT, token, "undefined")

                    customdata = urllib.parse.quote(customdata)
                    item.property["inputstream.adaptive.license_key"] = (
                        "https://ws-backendtv.rmcbfmplay.com/asgard-drm-widevine/public/licence|User-Agent="
                        + USER_AGENT + "&customdata=" + customdata +
                        "&Origin=https://www.rmcbfmplay.com&Content-Type=" +
                        "|R{SSM}|")
                    return item
示例#14
0
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):

    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
示例#16
0
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
示例#17
0
def get_video_url(plugin,
                  item_id,
                  video_url,
                  download_mode=False,
                  **kwargs):

    is_helper = inputstreamhelper.Helper('mpd')
    if not is_helper.check_inputstream():
        return False

    resp = urlquick.get(video_url)
    json_parser = json.loads(resp.text)

    if 'error' in json_parser:
        # Add Notification
        plugin.notify('ERROR', plugin.localize(30713))
        return False

    # Code from here : https://github.com/asciidisco/plugin.video.telekom-sport/blob/master/resources/lib/Utils.py
    # Thank you asciidisco
    payload = {
        'jsonrpc': '2.0',
        'id': 1,
        'method': 'Addons.GetAddonDetails',
        'params': {
            'addonid': 'inputstream.adaptive',
            'properties': ['enabled', 'version']
        }
    }
    # execute the request
    response = xbmc.executeJSONRPC(json.dumps(payload))
    responses_uni = text_type(response, 'utf-8', errors='ignore')
    response_serialized = json.loads(responses_uni)
    if 'error' not in list(response_serialized.keys()):
        result = response_serialized.get('result', {})
        addon = result.get('addon', {})
        if addon.get('enabled', False) is True:
            item = Listitem()
            item.path = json_parser["sources"][1]["src"]
            item.property['inputstreamaddon'] = 'inputstream.adaptive'
            item.property['inputstream.adaptive.manifest_type'] = 'mpd'
            item.label = get_selected_item_label()
            item.art.update(get_selected_item_art())
            item.info.update(get_selected_item_info())
            return item
    # Add Notification
    plugin.notify('ERROR', plugin.localize(30719))
    return False
示例#18
0
def playpodcast(plugin, path, title, **kwargs):
    item = Listitem()
    item.label = title
    item.art.update(get_selected_item_art())
    item.info.update(get_selected_item_info())

    # Deezer send directly the final url.
    if ".mp3" in path:
        item.path = path + "|User-Agent=" + USER_AGENT + "&Referer=https://www.deezer.com/"
    else:
        headers = {"User-Agent": USER_AGENT}
        resp = urlquick.get(path, headers=headers)
        data = resp.parse()
        if "bfmtv.com" in path:
            item.path = data.find(".//div[@class='audio-player']").get(
                'data-media-url')
    return item
def get_video_url(plugin, item_id, **kwargs):

    resp = urlquick.get(item_id,
                        headers={
                            "User-Agent": web_utils.get_random_ua()
                        },
                        max_age=-1).json()

    item = Listitem()
    item.path = resp["hls.m3u8"]
    item.property[INPUTSTREAM_PROP] = 'inputstream.adaptive'
    item.property['inputstream.adaptive.manifest_type'] = 'hls'

    item.label = get_selected_item_label()
    item.art.update(get_selected_item_art())
    item.info.update(get_selected_item_info())
    return item
示例#20
0
def get_live_url(plugin, item_id, **kwargs):

    live_id = ''
    for channel_name, live_id_value in list(LIST_LIVE_TV5MONDE.items()):
        if item_id == channel_name:
            live_id = live_id_value
    resp = urlquick.get(URL_TV5MONDE_LIVE + '%s.html' % live_id,
                        headers={'User-Agent': web_utils.get_random_ua()},
                        max_age=-1)
    live_json = re.compile(r'data-broadcast=\'(.*?)\'').findall(resp.text)[0]
    json_parser = json.loads(live_json)

    item = Listitem()
    item.path = json_parser[0]["url"]
    item.property[INPUTSTREAM_PROP] = 'inputstream.adaptive'
    item.property['inputstream.adaptive.manifest_type'] = 'hls'

    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, video_id, download_mode=False, **kwargs):

    video_format = 'dash'
    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

    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[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 % video_id

    return item
示例#22
0
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
示例#23
0
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_francetv_video_stream(plugin,
                              id_diffusion,
                              download_mode=False):

    geoip_value = web_utils.geoip()
    if not geoip_value:
        geoip_value = 'FR'
    resp = urlquick.get(URL_FRANCETV_CATCHUP_PROGRAM_INFO % (id_diffusion, geoip_value),
                        max_age=-1)
    json_parser = resp.json()

    if 'video' not in json_parser:
        plugin.notify('ERROR', plugin.localize(30716))
        return False

    all_video_datas = []
    video_datas = json_parser['video']
    # Implementer Caption (found case)
    # Implement DRM (found case)
    if video_datas['drm'] is not None:
        all_video_datas.append((video_datas['format'], video_datas['drm'], video_datas['token']))
    else:
        all_video_datas.append((video_datas['format'], None, video_datas['token']))

    url_selected = all_video_datas[0][2]
    if 'hls' in all_video_datas[0][0]:
        json_parser2 = json.loads(
            urlquick.get(url_selected, max_age=-1).text)
        final_video_url = json_parser2['url']
        if download_mode:
            return download.download_video(final_video_url)
        return final_video_url

    if 'dash' in all_video_datas[0][0]:

        is_helper = inputstreamhelper.Helper('mpd')
        if not is_helper.check_inputstream():
            return False

        item = Listitem()
        item.property[INPUTSTREAM_PROP] = 'inputstream.adaptive'
        item.property['inputstream.adaptive.manifest_type'] = 'mpd'
        item.label = get_selected_item_label()
        item.art.update(get_selected_item_art())
        item.info.update(get_selected_item_info())

        if all_video_datas[0][1]:
            if download_mode:
                xbmcgui.Dialog().ok(plugin.localize(14116), plugin.localize(30603))
                return False
            item.path = video_datas['url']
            token_request = json.loads('{"id": "%s", "drm_type": "%s", "license_type": "%s"}' % (id_diffusion, video_datas['drm_type'], video_datas['license_type']))
            token = urlquick.post(video_datas['token'], json=token_request).json()['token']
            license_request = '{"token": "%s", "drm_info": [D{SSM}]}' % token
            license_key = 'https://widevine-proxy.drm.technology/proxy|Content-Type=application%%2Fjson|%s|' % quote_plus(license_request)
            item.property['inputstream.adaptive.license_type'] = 'com.widevine.alpha'
            item.property['inputstream.adaptive.license_key'] = license_key
        else:
            headers = {
                'User-Agent':
                web_utils.get_random_ua()
            }
            json_parser2 = json.loads(urlquick.get(url_selected, headers=headers, max_age=-1).text)
            resp3 = urlquick.get(json_parser2['url'], headers=headers, max_age=-1, allow_redirects=False)
            location_url = resp3.headers['location']
            item.path = location_url
            item.property['inputstream.adaptive.stream_headers'] = 'User-Agent=%s' % web_utils.get_random_ua()
            if download_mode:
                return download.download_video(item.path)
        return item

    # Return info the format is not known
    return False
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"]
示例#26
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
示例#27
0
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
示例#28
0
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
示例#29
0
def add_item_to_favourites(plugin, is_playable=False, item_infos={}):
    """Callback function of the 'Add to add-on favourites' item context menu

    Args:
        plugin (codequick.script.Script)
        is_playable (bool): If 'item' is playable
        item_infos (dict)
    """

    # Need to use same keywords as
    # https://scriptmodulecodequick.readthedocs.io/en/latest/_modules/codequick/listing.html#Listitem.from_dict
    # in order to be able to directly use `Listitem.from_dict` later
    item_dict = {}

    # --> subtitles (TODO)
    # item_dict['subtitles'] = list(item.subtitles)

    # --> art
    item_dict['art'] = get_selected_item_art()

    # --> info
    item_dict['info'] = get_selected_item_info()

    # --> stream
    item_dict['stream'] = get_selected_item_stream()

    # --> context (TODO)
    item_dict['context'] = []

    # --> properties (TODO)
    item_dict['properties'] = {}

    # --> params
    item_dict['params'] = get_selected_item_params()

    # --> label
    item_dict['label'] = get_selected_item_label()

    if item_infos:
        # This item comes from tv_guide_menu
        # We need to remove guide TV related
        # elements

        item_id = item_dict['params']['item_id']
        item_dict['label'] = get_item_label(item_id, item_infos)

        item_dict['art']["thumb"] = ''
        if 'thumb' in item_infos:
            item_dict['art']["thumb"] = get_item_media_path(
                item_infos['thumb'])

        item_dict['art']["fanart"] = ''
        if 'fanart' in item_infos:
            item_dict['art']["fanart"] = get_item_media_path(
                item_infos['fanart'])

        item_dict['info']['plot'] = ''

    # Extract the callback
    item_path = xbmc.getInfoLabel('ListItem.Path')
    item_dict['callback'] = item_path.replace(
        'plugin://plugin.video.catchuptvandmore', '')

    s = mem_storage.MemStorage('fav')
    prefix = ''
    try:
        prefix = s['prefix']
    except KeyError:
        pass

    label_proposal = item_dict['label']
    if prefix != '':
        label_proposal = prefix + ' - ' + label_proposal

    # Ask the user to edit the label
    label = utils.keyboard(plugin.localize(30801), label_proposal)

    # If user aborded do not add this item to favourite
    if label == '':
        return False

    item_dict['label'] = label
    item_dict['params']['_title_'] = label
    item_dict['info']['title'] = label

    item_dict['params']['is_playable'] = is_playable
    item_dict['params']['is_folder'] = not is_playable

    # Compute fav hash
    item_hash = md5(str(item_dict).encode('utf-8')).hexdigest()

    # Add this item to favourites json file
    fav_dict = get_fav_dict_from_json()
    item_dict['params']['order'] = len(fav_dict)

    fav_dict[item_hash] = item_dict

    # Save json file with new fav_dict
    save_fav_dict_in_json(fav_dict)

    Script.notify(Script.localize(30033),
                  Script.localize(30805),
                  display_time=7000)
示例#30
0
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