コード例 #1
0
def get_francetv_live_stream(plugin, live_id):

    # Move Live TV on the new API
    json_parser_liveId = json.loads(
        urlquick.get(URL_FRANCETV_LIVE_PROGRAM_INFO % live_id,
                     max_age=-1).text)

    final_url = ''
    geoip_value = web_utils.geoip()
    if not geoip_value:
        geoip_value = 'FR'
    for video in json_parser_liveId['videos']:
        if 'format' not in video:
            continue

        if 'hls_v' not in video['format'] and video['format'] != 'hls':
            continue

        if video['geoblocage'] is not None:
            for value_geoblocage in video['geoblocage']:
                if geoip_value == value_geoblocage:
                    final_url = video['url']
        else:
            final_url = video['url']

    if final_url == '':
        return None

    json_parser2 = json.loads(urlquick.get(URL_FRANCETV_HDFAUTH_URL % (final_url), max_age=-1).text)

    return json_parser2['url'] + '|User-Agent=%s' % web_utils.get_random_ua()
コード例 #2
0
def get_francetv_video_stream(plugin,
                              id_diffusion,
                              item_dict=None,
                              download_mode=False,
                              video_label=None):

    geoip_value = web_utils.geoip()
    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, video_label)
        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 = item_dict['label']
        item.info.update(item_dict['info'])
        item.art.update(item_dict['art'])

        return item
    else:
        # Return info the format is not known
        return False
コード例 #3
0
def get_francetv_live_stream(plugin, live_id):
    geoip_value = web_utils.geoip()
    if not geoip_value:
        geoip_value = 'FR'

    # Move Live TV on the new API
    json_parser_liveId = json.loads(
        urlquick.get(URL_FRANCETV_PROGRAM_INFO % (live_id, geoip_value),
                     max_age=-1).text)['video']

    try:
        final_url = json_parser_liveId['url']
    except Exception:
        return None

    json_parser2 = json.loads(
        urlquick.get(URL_FRANCETV_HDFAUTH_URL % (final_url), max_age=-1).text)
    return json_parser2['url'] + '|User-Agent=%s' % web_utils.get_random_ua()
コード例 #4
0
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