コード例 #1
0
def get_video_url(url, protocol='http'):
    response = requests.get(url, headers=__HEADERS)
    html = response.read()
    match = re.search('FlashPlayer" data-jsb="(.*?)"', html)
    if match:
        parser = HTMLParser()
        response.text = parser.unescape(match.group(1))
        json_data = response.json()
        parts = json_data['config']['initial_video']['parts']
        geoblocked_parts = 0
        stacked_url = ''
        for part in parts:
            if part['is_geo_ip_blocked']:
                geoblocked_parts += 1
            streams = part['sources']
            if not streams:
                continue
            for stream in streams:
                if stream['protocol'] == protocol:
                    stacked_url += stream['src'] + ' , '
                    break
        if geoblocked_parts == len(parts) and not is_user_from_austria():
            return gui.warning(
                'Video nicht abspielbar',
                'Dieses Video ist nur in Österreich verfügbar!')
        if stacked_url:
            return 'stack://' + stacked_url[:-3]
    return gui.warning('Video nicht gefunden',
                       'Es konnte kein Videolink ermittelt werden!')
コード例 #2
0
ファイル: api.py プロジェクト: kodinerds/repo
def get_video_url(url, protocol='http'):
    response = requests.get(url, headers=__HEADERS)
    html = response.read()
    match = re.search('FlashPlayer" data-jsb="(.*?)"', html)
    if match:
        parser = HTMLParser()
        response.text = parser.unescape(match.group(1))
        json_data = response.json()
        parts = json_data['config']['initial_video']['parts']
        geoblocked_parts = 0
        stacked_url = ''
        for part in parts:
            if part['is_geo_ip_blocked']:
                geoblocked_parts += 1
            streams = part['sources']
            if not streams:
                continue
            for stream in streams:
                if stream['protocol'] == protocol:
                    stacked_url += stream['src'] + ' , '
                    break
        if geoblocked_parts == len(parts) and not is_user_from_austria():
            return gui.warning('Video nicht abspielbar', 'Dieses Video ist nur in Österreich verfügbar!')
        if stacked_url:
            return 'stack://' + stacked_url[:-3]
    return gui.warning('Video nicht gefunden', 'Es konnte kein Videolink ermittelt werden!')
コード例 #3
0
def get_playlist(url, protocol='http'):
    response = requests.get(url, headers=__HEADERS)
    html = response.read()
    match = re.search('FlashPlayer" data-jsb="(.*?)"', html)
    playlist = [
    ]  # [(title,image_url,stream_url),(title,image_url,stream_url),...]
    if match:
        parser = HTMLParser()
        response.text = parser.unescape(match.group(1))
        json_data = response.json()
        parts = json_data['config']['initial_video']['parts']
        geoblocked_parts = 0
        for part in parts:
            if part['is_geo_ip_blocked']:
                geoblocked_parts += 1
            streams = part['sources']
            if not streams:
                continue
            stream_part = part['title'], part['preview_image_url'], streams[0][
                'src']
            for stream in streams:
                if stream['protocol'] == protocol:
                    stream_part = part['title'], part[
                        'preview_image_url'], stream['src']
                    break
            playlist.append(stream_part)
        if geoblocked_parts == len(parts) and not is_user_from_austria():
            return gui.warning(
                'Video nicht abspielbar',
                'Dieses Video ist nur in Österreich verfügbar!')
        if playlist:
            return playlist
    return gui.warning('Video nicht gefunden',
                       'Es konnte kein Videolink ermittelt werden!')
コード例 #4
0
ファイル: api.py プロジェクト: kodinerds/repo
def get_playlist(url, protocol='http'):
    response = requests.get(url, headers=__HEADERS)
    html = response.read()
    match = re.search('FlashPlayer" data-jsb="(.*?)"', html)
    playlist = []  # [(title,image_url,stream_url),(title,image_url,stream_url),...]
    if match:
        parser = HTMLParser()
        response.text = parser.unescape(match.group(1))
        json_data = response.json()
        parts = json_data['config']['initial_video']['parts']
        geoblocked_parts = 0
        for part in parts:
            if part['is_geo_ip_blocked']:
                geoblocked_parts += 1
            streams = part['sources']
            if not streams:
                continue
            stream_part = part['title'], part['preview_image_url'], streams[0]['src']
            for stream in streams:
                if stream['protocol'] == protocol:
                    stream_part = part['title'], part['preview_image_url'], stream['src']
                    break
            playlist.append(stream_part)
        if geoblocked_parts == len(parts) and not is_user_from_austria():
            return gui.warning('Video nicht abspielbar', 'Dieses Video ist nur in Österreich verfügbar!')
        if playlist:
            return playlist
    return gui.warning('Video nicht gefunden', 'Es konnte kein Videolink ermittelt werden!')