IPTV mytvsuper 转直链 PHP(方便 tivimate&影视等)

stronghu · 2024年05月20日 · 最后由 lyy888119 回复于 2024年06月12日 · 3596 次阅读
<?php

$CHANNEL_LIST = array(
    'J' => array(
   'name' => '翡翠台',
   'license' => '0958b9c657622c465a6205eb2252b8ed:2d2fd7b1661b1e28de38268872b48480',
   'logo' => 'https://github.com/wanglindl/TVlogo/blob/main/img/TVB1.png?raw=true'
    ),
    'JUHD' => array(
   'name' => '翡翠台 4K',
   'license' => '2c045f5adb26d391cc41cd01f00416fa:fc146771a9b096fc4cb57ffe769861be',
   'logo' => 'https://github.com/wanglindl/TVlogo/blob/main/img/TVB1.png?raw=true'
    ),
    'B' => array(
   'name' => 'TVBplus',
   'license' => '56603b65fa1d7383b6ef0e73b9ae69fa:5d9d8e957d2e45d8189a56fe8665aaaa',
   'logo' => 'https://raw.githubusercontent.com/wanglindl/TVlogo/main/img/TVB3.png'
    ),
    'P' => array(
   'name' => '明珠台',
   'license' => 'e04facdd91354deee318c674993b74c1:8f97a629de680af93a652c3102b65898',
   'logo' => 'https://github.com/wanglindl/TVlogo/blob/main/img/TVB1.png?raw=true'
    ),
    'CWIN' => array(
   'name' => 'Super Free',
   'license' => '0737b75ee8906c00bb7bb8f666da72a0:15f515458cdb5107452f943a111cbe89',
   'logo' => ''
    ),
    'TVG' => array(
   'name' => '黄金翡翠台',
   'license' => '8fe3db1a24969694ae3447f26473eb9f:5cce95833568b9e322f17c61387b306f',
   'logo' => 'https://github.com/sparkssssssssss/epg/blob/main/logo/%E9%BB%84%E9%87%91%E7%BF%A1%E7%BF%A0%E5%8F%B0.png?raw=true'
    ),
    'C' => array(
   'name' => '无线新闻台',
   'license' => '90a0bd01d9f6cbb39839cd9b68fc26bc:51546d1f2af0547f0e961995b60a32a1',
   'logo' => 'https://raw.githubusercontent.com/wanglindl/TVlogo/main/img/TVB4.png'
    ),
    'CTVE' => array(
   'name' => '娱乐新闻台',
   'license' => '6fa0e47750b5e2fb6adf9b9a0ac431a3:a256220e6c2beaa82f4ca5fba4ec1f95',
   'logo' => 'https://github.com/sparkssssssssss/epg/blob/main/logo/%E5%A8%B1%E4%B9%90%E6%96%B0%E9%97%BB%E5%8F%B0.png?raw=true'
    ),
    'PCC' => array(
   'name' => '凤凰卫视中文台',
   'license' => '7bca0771ba9205edb5d467ce2fdf0162:eb19c7e3cea34dc90645e33f983b15ab',
   'logo' => 'https://raw.githubusercontent.com/wanglindl/TVlogo/main/img/Phoenix1.png'
    ),
    'PIN' => array(
   'name' => '凤凰卫视资讯台',
   'license' => '83f7d313adfc0a5b978b9efa0421ce25:ecdc8065a46287bfb58e9f765e4eec2b',
   'logo' => 'https://raw.githubusercontent.com/wanglindl/TVlogo/main/img/Phoenix2.png'
    ),
    'PHK' => array(
   'name' => '凤凰卫视香港台',
   'license' => 'cde62e1056eb3615dab7a3efd83f5eb4:b8685fbecf772e64154630829cf330a3',
   'logo' => 'https://raw.githubusercontent.com/wanglindl/TVlogo/main/img/Phoenix3.png'
    ),
    'EVT1' => array(
   'name' => 'myTV SUPER直播足球1台',
   'license' => 'e8ca7903e25450d85cb32b3057948522:d5db5c03608f5f6c8a382c6abcb829e4',
   'logo' => ''
    )
);

function get_mytvsuper($channel) {
    global $CHANNEL_LIST;

    if (!array_key_exists($channel, $CHANNEL_LIST)) {
   return '频道代号错误';
    }

    $api_token = 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJib3NzX2lkIjoiODUwNDY0NTgwIiwiZGV2aWNlX3Rva2VuIjoiWHp6anMzYTVKTms2TFpnZmJQeFZHR2QzIiwiZGV2aWNlX2lkIjoiTldGalptSmxNREF0TkRJNU5TMDBaakV3TFRrNFl6QXRNbUkwT0RCbFpXRTJaVEV3IiwiZGV2aWNlX3R5cGUiOiJ3ZWIiLCJkZXZpY2Vfb3MiOiJicm93c2VyIiwiZHJtX2lkIjoiTldGalptSmxNREF0TkRJNU5TMDBaakV3TFRrNFl6QXRNbUkwT0RCbFpXRTJaVEV3IiwiZXh0cmEiOnsicHJvZmlsZV9pZCI6MX0sImlhdCI6MTcwOTgwNTA3NywiZXhwIjoxNzA5ODA4Njc3fQ.XG-C6gWxLgbBRQ3ttKn68AKMQLOg6SxTpbmHxXl_qI2dbjd1eFFmwB9kD1yd2N_X8HxLPBwJukD4lygIKxbBGrQQDY_1vNd76TldllaeE2BC3fUtc-kAFOU4JwbUkfFYsWVm3v2JP-YGM2GGlhFqN_3170WDAi2Gq-R0tZckeFNWk7jOSShqkE0E7L3eqJ09sDG76R-PCbdpnCIxaY_NXtoYRfIoVQZA9QysExUyO6hQGUxLaTvJDtflX_ZM3OiqTMndHp1p0cDsINnpFokD6Yby5XS18RjQ-Dn1XJznj7-sRjlaGgyIIBoJjxsR2oD5S8teA5S6x7w3Dv6uTO3bWVV9J60E6jguGVqKnSYJ4Rx8A1TgyUTT_g57key6UFIiEhkHYqk7s3H01V-lHffNp5zDo9UrCdaO6maW_ZeA85ohR6P1PMh9EakQ5A-vok60s2oqyokKHfyrQvcodsI-MTC9mKegjJzgV2-HBgyylyj6B2ewvE4icDD25UdspWgbc33NrRpe_kgPxgVKF4cgKCD-S1AT3WrOaqKnPfPvhqmlciwlpZrUqZg09BqcazWPoyWAp2nqf93H6tlDqMrtAQgvft3Nd8-cM7jYx-WvzqRrCRpZ8vRSv11UdezKzR2Jm4H64KTWbs3GxB5vboZaeypdEzQW6PipPpftqRnNMQU'; // 请自行获取
    $headers = array(
   'Accept: application/json',
   'Authorization: Bearer ' . $api_token,
   'Accept-Language: zh-CN,zh-Hans;q=0.9',
   'Host: user-api.mytvsuper.com',
   'Origin: https://www.mytvsuper.com',
   'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.5.2 Safari/605.1.15',
   'Referer: https://www.mytvsuper.com/',
   'X-Forwarded-For: 210.6.4.148'  // 香港原生IP  210.6.4.148
    );

    $params = array(
   'platform' => 'android_tv',
   'network_code' => $channel
    );

    $url = 'https://user-api.mytvsuper.com/v1/channel/checkout?' . http_build_query($params);
    $context = stream_context_create(array('http' => array('header' => implode("\r\n", $headers))));
    $response = file_get_contents($url, false, $context);

    if ($response === false) {
   return '请求失败';
    }

    $response_json = json_decode($response, true);
    $profiles = $response_json['profiles'];

    $play_url = '';
    foreach ($profiles as $profile) {
   if ($profile['quality'] === 'high') {
  $play_url = $profile['streaming_path'];
  break;
   }
    }

    if (empty($play_url)) {
   return '未找到播放地址';
    }

    $play_url = explode('&p=', $play_url)[0];

    $license_key =$CHANNEL_LIST[    $channel]['license'];
    $channel_name =$CHANNEL_LIST[    $channel]['name'];
    $channel_logo =$CHANNEL_LIST[    $channel]['logo'];
    $m3u_content = "#EXTINF:-1 tvg-id=\"" .$channel . "\" tvg-logo=\"" .$channel_logo . "\"," .$channel_name . "\n";
    $m3u_content .= "#KODIPROP:inputstream.adaptive.manifest_type=mpd\n";
    $m3u_content .= "#KODIPROP:inputstream.adaptive.license_type=clearkey\n";
    $m3u_content .= "#KODIPROP:inputstream.adaptive.license_key=" .$license_key . "\n";
    $m3u_content .=$play_url . "\n";

    return $m3u_content;
}

// 创建或打开文件用于写入
$m3u_file = fopen('mytvfree.m3u', 'w');

// 写入 M3U 文件的头部
fwrite($m3u_file, "#EXTM3U\n");

// 遍历所有频道并写入每个频道的 M3U 内容
foreach ($CHANNEL_LIST as $channel_code => $channel_info) {
    $m3u_content = get_mytvsuper($channel_code);
    fwrite($m3u_file, $m3u_content);
}

// 关闭文件
fclose($m3u_file);

echo "所有频道的 M3U 播放列表已生成并保存为 'mytvfree.m3u'。";

?>

偷懒找群友之前分享的改的,缺的 logo 自己可以加加,php 运行生成 m3u,可用 crontab -e 每天定时运行更新即可,或其他方式自行修改,不懂问 GPT

tivimate 还是不能播放,什么原因

一次成功,感谢大佬

谢谢分享

谢谢分享👍

怎么弄的啊?

还是只能在 ott 播,在 tivimate 黑屏播不了。

非常感谢 让 chatgpt 改了一下 tivimate5.04 测试正常播放。

import requests
import json

CHANNEL_LIST = {
    'J': {
        'name': '翡翠台',
        'license': '0958b9c657622c465a6205eb2252b8ed:2d2fd7b1661b1e28de38268872b48480',
        'logo': 'https://github.com/wanglindl/TVlogo/blob/main/img/TVB1.png?raw=true',
        'license_key': 'https://vercel-php-clearkey-hex-base64-json.vercel.app/api/results.php?keyid=0958b9c657622c465a6205eb2252b8ed&key=2d2fd7b1661b1e28de38268872b48480'
    },
    'JUHD': {
        'name': '翡翠台 4K',
        'license': '2c045f5adb26d391cc41cd01f00416fa:fc146771a9b096fc4cb57ffe769861be',
        'logo': 'https://github.com/wanglindl/TVlogo/blob/main/img/TVB1.png?raw=true',
        'license_key': 'https://vercel-php-clearkey-hex-base64-json.vercel.app/api/results.php?keyid=2c045f5adb26d391cc41cd01f00416fa&key=fc146771a9b096fc4cb57ffe769861be'
    },
    'B': {
        'name': 'TVBplus',
        'license': '56603b65fa1d7383b6ef0e73b9ae69fa:5d9d8e957d2e45d8189a56fe8665aaaa',
        'logo': 'https://raw.githubusercontent.com/wanglindl/TVlogo/main/img/TVB3.png',
        'license_key': 'https://vercel-php-clearkey-hex-base64-json.vercel.app/api/results.php?keyid=56603b65fa1d7383b6ef0e73b9ae69fa&key=5d9d8e957d2e45d8189a56fe8665aaaa'
    },
    'P': {
        'name': '明珠台',
        'license': 'e04facdd91354deee318c674993b74c1:8f97a629de680af93a652c3102b65898',
        'logo': 'https://github.com/wanglindl/TVlogo/blob/main/img/TVB1.png?raw=true',
        'license_key': 'https://vercel-php-clearkey-hex-base64-json.vercel.app/api/results.php?keyid=e04facdd91354deee318c674993b74c1&key=8f97a629de680af93a652c3102b65898'
    },
    'CWIN': {
        'name': 'Super Free',
        'license': '0737b75ee8906c00bb7bb8f666da72a0:15f515458cdb5107452f943a111cbe89',
        'logo': 'https://raw.githubusercontent.com/sparkssssssssss/epg/main/logo/黄金翡翠台.png',
        'license_key': 'https://vercel-php-clearkey-hex-base64-json.vercel.app/api/results.php?keyid=0737b75ee8906c00bb7bb8f666da72a0&key=15f515458cdb5107452f943a111cbe89'
    },
    'TVG': {
        'name': '黄金翡翠台',
        'license': '8fe3db1a24969694ae3447f26473eb9f:5cce95833568b9e322f17c61387b306f',
        'logo': 'https://github.com/sparkssssssssss/epg/blob/main/logo/%E9%BB%84%E9%87%91%E7%BF%A1%E7%BF%A0%E5%8F%B0.png?raw=true',
        'license_key': 'https://vercel-php-clearkey-hex-base64-json.vercel.app/api/results.php?keyid=8fe3db1a24969694ae3447f26473eb9f&key=5cce95833568b9e322f17c61387b306f'
    },
    'C': {
        'name': '无线新闻台',
        'license': '90a0bd01d9f6cbb39839cd9b68fc26bc:51546d1f2af0547f0e961995b60a32a1',
        'logo': 'https://raw.githubusercontent.com/wanglindl/TVlogo/main/img/TVB4.png',
        'license_key': 'https://vercel-php-clearkey-hex-base64-json.vercel.app/api/results.php?keyid=90a0bd01d9f6cbb39839cd9b68fc26bc&key=51546d1f2af0547f0e961995b60a32a1'
    },
    'CTVE': {
        'name': '娱乐新闻台',
        'license': '6fa0e47750b5e2fb6adf9b9a0ac431a3:a256220e6c2beaa82f4ca5fba4ec1f95',
        'logo': 'https://github.com/sparkssssssssss/epg/blob/main/logo/%E5%A8%B1%E4%B9%90%E6%96%B0%E9%97%BB%E5%8F%B0.png?raw=true',
        'license_key': 'https://vercel-php-clearkey-hex-base64-json.vercel.app/api/results.php?keyid=6fa0e47750b5e2fb6adf9b9a0ac431a3&key=a256220e6c2beaa82f4ca5fba4ec1f95'
    },
    'PCC': {
        'name': '凤凰卫视中文台',
        'license': '7bca0771ba9205edb5d467ce2fdf0162:eb19c7e3cea34dc90645e33f983b15ab',
        'logo': 'https://raw.githubusercontent.com/wanglindl/TVlogo/main/img/Phoenix1.png',
        'license_key': 'https://vercel-php-clearkey-hex-base64-json.vercel.app/api/results.php?keyid=7bca0771ba9205edb5d467ce2fdf0162&key=eb19c7e3cea34dc90645e33f983b15ab'
    },
    'PIN': {
        'name': '凤凰卫视资讯台',
        'license': '83f7d313adfc0a5b978b9efa0421ce25:ecdc8065a46287bfb58e9f765e4eec2b',
        'logo': 'https://raw.githubusercontent.com/wanglindl/TVlogo/main/img/Phoenix2.png',
        'license_key': 'https://vercel-php-clearkey-hex-base64-json.vercel.app/api/results.php?keyid=83f7d313adfc0a5b978b9efa0421ce25&key=ecdc8065a46287bfb58e9f765e4eec2b'
    },
    'PHK': {
        'name': '凤凰卫视香港台',
        'license': 'cde62e1056eb3615dab7a3efd83f5eb4:b8685fbecf772e64154630829cf330a3',
        'logo': 'https://raw.githubusercontent.com/wanglindl/TVlogo/main/img/Phoenix3.png',
        'license_key': 'https://vercel-php-clearkey-hex-base64-json.vercel.app/api/results.php?keyid=cde62e1056eb3615dab7a3efd83f5eb4&key=b8685fbecf772e64154630829cf330a3'
    },
    'EVT1': {
        'name': 'myTV SUPER直播足球1台',
        'license': 'e8ca7903e25450d85cb32b3057948522:d5db5c03608f5f6c8a382c6abcb829e4',
        'logo': 'https://raw.githubusercontent.com/sparkssssssssss/epg/main/logo/黄金翡翠台.png',
        'license_key': 'https://vercel-php-clearkey-hex-base64-json.vercel.app/api/results.php?keyid=e8ca7903e25450d85cb32b3057948522&key=d5db5c03608f5f6c8a382c6abcb829e4'
    }
}

def get_mytvsuper(channel):
    if channel not in CHANNEL_LIST:
        return '频道代号错误'

    api_token = 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJib3NzX2lkIjoiODUwNDY0NTgwIiwiZGV2aWNlX3Rva2VuIjoiWHp6anMzYTVKTms2TFpnZmJQeFZHR2QzIiwiZGV2aWNlX2lkIjoiTldGalptSmxNREF0TkRJNU5TMDBaakV3TFRrNFl6QXRNbUkwT0RCbFpXRTJaVEV3IiwiZGV2aWNlX3R5cGUiOiJ3ZWIiLCJkZXZpY2Vfb3MiOiJicm93c2VyIiwiZHJtX2lkIjoiTldGalptSmxNREF0TkRJNU5TMDBaakV3TFRrNFl6QXRNbUkwT0RCbFpXRTJaVEV3IiwiZXh0cmEiOnsicHJvZmlsZV9pZCI6MX0sImlhdCI6MTcwOTgwNTA3NywiZXhwIjoxNzA5ODA4Njc3fQ.XG-C6gWxLgbBRQ3ttKn68AKMQLOg6SxTpbmHxXl_qI2dbjd1eFFmwB9kD1yd2N_X8HxLPBwJukD4lygIKxbBGrQQDY_1vNd76TldllaeE2BC3fUtc-kAFOU4JwbUkfFYsWVm3v2JP-YGM2GGlhFqN_3170WDAi2Gq-R0tZckeFNWk7jOSShqkE0E7L3eqJ09sDG76R-PCbdpnCIxaY_NXtoYRfIoVQZA9QysExUyO6hQGUxLaTvJDtflX_ZM3OiqTMndHp1p0cDsINnpFokD6Yby5XS18RjQ-Dn1XJznj7-sRjlaGgyIIBoJjxsR2oD5S8teA5S6x7w3Dv6uTO3bWVV9J60E6jguGVqKnSYJ4Rx8A1TgyUTT_g57key6UFIiEhkHYqk7s3H01V-lHffNp5zDo9UrCdaO6maW_ZeA85ohR6P1PMh9EakQ5A-vok60s2oqyokKHfyrQvcodsI-MTC9mKegjJzgV2-HBgyylyj6B2ewvE4icDD25UdspWgbc33NrRpe_kgPxgVKF4cgKCD-S1AT3WrOaqKnPfPvhqmlciwlpZrUqZg09BqcazWPoyWAp2nqf93H6tlDqMrtAQgvft3Nd8-cM7jYx-WvzqRrCRpZ8vRSv11UdezKzR2Jm4H64KTWbs3GxB5vboZaeypdEzQW6PipPpftqRnNMQU'  # 请自行获取
    headers = {
        'Accept': 'application/json',
        'Authorization': 'Bearer ' + api_token,
        'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
        'Host': 'user-api.mytvsuper.com',
        'Origin': 'https://www.mytvsuper.com',
        'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.5.2 Safari/605.1.15',
        'Referer': 'https://www.mytvsuper.com/',
        'X-Forwarded-For': '210.6.4.148'  # 香港原生IP  210.6.4.148
    }

    params = {
        'platform': 'android_tv',
        'network_code': channel
    }

    url = 'https://user-api.mytvsuper.com/v1/channel/checkout'
    response = requests.get(url, headers=headers, params=params)

    if response.status_code != 200:
        return '请求失败'

    response_json = response.json()
    profiles = response_json.get('profiles', [])

    play_url = ''
    for profile in profiles:
        if profile.get('quality') == 'high':
            play_url = profile.get('streaming_path', '')
            break

    if not play_url:
        return '未找到播放地址'

    play_url = play_url.split('&p=')[0]

    license_key = CHANNEL_LIST[channel]['license_key']
    channel_name = CHANNEL_LIST[channel]['name']
    channel_logo = CHANNEL_LIST[channel]['logo']
    m3u_content = f"#EXTINF:-1 tvg-id=\"{channel}\" tvg-logo=\"{channel_logo}\",{channel_name}\n"
    m3u_content += "#KODIPROP:inputstream.adaptive.manifest_type=mpd\n"
    m3u_content += "#KODIPROP:inputstream.adaptive.license_type=clearkey\n"
    m3u_content += f"#KODIPROP:inputstream.adaptive.license_key={license_key}\n"
    m3u_content += f"{play_url}\n"

    return m3u_content

# 创建或打开文件用于写入
with open('mytvfree.m3u', 'w', encoding='utf-8') as m3u_file:
    # 写入 M3U 文件的头部
    m3u_file.write("#EXTM3U url-tvg=\"https://xmltv.bph.workers.dev\"\n")

    # 遍历所有频道并写入每个频道的 M3U 内容
    for channel_code in CHANNEL_LIST.keys():
        m3u_content = get_mytvsuper(channel_code)
        m3u_file.write(m3u_content)

print("所有频道的 M3U 播放列表已生成并保存为 'mytvfree.m3u'")

lingch 回复

我也只是 ott 能看

eyou 回复

请问你 tivi 是入正了吗?我的 2.1.5 破解版不能放

挺好用的,谢谢分享!

Guo_123 回复

正版

Guo_123 回复

2.1.5 不支持

eyou 回复

请问这是改的 php 还是 workers?

补充一下创世电视和港版 CCTV1 也是免费观看的

jefflyrop 回复

python

謝謝大神分享

用电话 ott 播,4k 翡翠台播不了,是什么问题 其他频道正常

有这个频道全部的 epg.xml 吗?

会有 VIUTV 和 VIUTV SIX 的转直链 PHP 放 OTT/TIVIMATE 播放的吗

const CHANNEL_LIST = {
    'JUHD': {
        'name': '翡翠台超高清',
        'license': '2c045f5adb26d391cc41cd01f00416fa:fc146771a9b096fc4cb57ffe769861be',
        'logo': 'https://assets.livednow.com/logo/翡翠台.png',
        'license_key': 'https://vercel-php-clearkey-hex-base64-json.vercel.app/api/results.php?keyid=2c045f5adb26d391cc41cd01f00416fa&key=fc146771a9b096fc4cb57ffe769861be'
    },
    'J': {
        'name': '翡翠台',
        'license': '0958b9c657622c465a6205eb2252b8ed:2d2fd7b1661b1e28de38268872b48480',
        'logo': 'https://assets.livednow.com/logo/翡翠台.png',
        'license_key': 'https://vercel-php-clearkey-hex-base64-json.vercel.app/api/results.php?keyid=0958b9c657622c465a6205eb2252b8ed&key=2d2fd7b1661b1e28de38268872b48480'
    },
    'B': {
        'name': 'TVB plus',
        'license': '56603b65fa1d7383b6ef0e73b9ae69fa:5d9d8e957d2e45d8189a56fe8665aaaa',
        'logo': 'https://img.sky4k.top/TVB_Plus_CheerVisionTV.png',
        'license_key': 'https://vercel-php-clearkey-hex-base64-json.vercel.app/api/results.php?keyid=56603b65fa1d7383b6ef0e73b9ae69fa&key=5d9d8e957d2e45d8189a56fe8665aaaa'
    },
    'P': {
        'name': '明珠台',
        'license': 'e04facdd91354deee318c674993b74c1:8f97a629de680af93a652c3102b65898',
        'logo': 'https://assets.livednow.com/logo/明珠台.png',
        'license_key': 'https://vercel-php-clearkey-hex-base64-json.vercel.app/api/results.php?keyid=e04facdd91354deee318c674993b74c1&key=8f97a629de680af93a652c3102b65898'
    },
    'CWIN': {
        'name': 'Super Free',
        'license': '0737b75ee8906c00bb7bb8f666da72a0:15f515458cdb5107452f943a111cbe89',
        'logo': 'https://raw.githubusercontent.com/sparkssssssssss/epg/main/logo/黄金翡翠台.png',
        'license_key': 'https://vercel-php-clearkey-hex-base64-json.vercel.app/api/results.php?keyid=0737b75ee8906c00bb7bb8f666da72a0&key=15f515458cdb5107452f943a111cbe89'
    },
    'TVG': {
        'name': '黃金翡翠台',
        'license': '8fe3db1a24969694ae3447f26473eb9f:5cce95833568b9e322f17c61387b306f',
        'logo': 'https://github.com/sparkssssssssss/epg/blob/main/logo/%E9%BB%84%E9%87%91%E7%BF%A1%E7%BF%A0%E5%8F%B0.png?raw=true',
        'license_key': 'https://vercel-php-clearkey-hex-base64-json.vercel.app/api/results.php?keyid=8fe3db1a24969694ae3447f26473eb9f&key=5cce95833568b9e322f17c61387b306f'
    },
    'C': {
        'name': '無綫新聞台',
        'license': '90a0bd01d9f6cbb39839cd9b68fc26bc:51546d1f2af0547f0e961995b60a32a1',
        'logo': 'https://assets.livednow.com/logo/無線新聞台.png',
        'license_key': 'https://vercel-php-clearkey-hex-base64-json.vercel.app/api/results.php?keyid=90a0bd01d9f6cbb39839cd9b68fc26bc&key=51546d1f2af0547f0e961995b60a32a1'
    },
    'CTVE': {
        'name': '娛樂新聞台',
        'license': '6fa0e47750b5e2fb6adf9b9a0ac431a3:a256220e6c2beaa82f4ca5fba4ec1f95',
        'logo': 'https://github.com/sparkssssssssss/epg/blob/main/logo/%E5%A8%B1%E4%B9%90%E6%96%B0%E9%97%BB%E5%8F%B0.png?raw=true',
        'license_key': 'https://vercel-php-clearkey-hex-base64-json.vercel.app/api/results.php?keyid=6fa0e47750b5e2fb6adf9b9a0ac431a3&key=a256220e6c2beaa82f4ca5fba4ec1f95'
    },
    'PCC': {
        'name': '鳳凰衛視中文台',
        'license': '7bca0771ba9205edb5d467ce2fdf0162:eb19c7e3cea34dc90645e33f983b15ab',
        'logo': 'https://assets.livednow.com/logo/鳳凰中文.png',
        'license_key': 'https://vercel-php-clearkey-hex-base64-json.vercel.app/api/results.php?keyid=7bca0771ba9205edb5d467ce2fdf0162&key=eb19c7e3cea34dc90645e33f983b15ab'
    },
    'PIN': {
        'name': '鳳凰衛視資訊台',
        'license': '83f7d313adfc0a5b978b9efa0421ce25:ecdc8065a46287bfb58e9f765e4eec2b',
        'logo': 'https://assets.livednow.com/logo/鳳凰資訊.png',
        'license_key': 'https://vercel-php-clearkey-hex-base64-json.vercel.app/api/results.php?keyid=83f7d313adfc0a5b978b9efa0421ce25&key=ecdc8065a46287bfb58e9f765e4eec2b'
    },
    'PHK': {
        'name': '鳳凰衛視香港台',
        'license': 'cde62e1056eb3615dab7a3efd83f5eb4:b8685fbecf772e64154630829cf330a3',
        'logo': 'https://assets.livednow.com/logo/鳳凰香港.png',
        'license_key': 'https://vercel-php-clearkey-hex-base64-json.vercel.app/api/results.php?keyid=cde62e1056eb3615dab7a3efd83f5eb4&key=b8685fbecf772e64154630829cf330a3'
    },
    'CC1': {
        'name': '中央電視台綜合頻道 (港澳版)',
        'license': 'e50b18fee7cab76b9f2822e2ade8773a:2e2e8602b6d835ccf10ee56a9a7d91a2',
        'logo': 'https://assets.livednow.com/logo/CCTV1.png',
        'license_key': 'https://vercel-php-clearkey-hex-base64-json.vercel.app/api/results.php?keyid=e50b18fee7cab76b9f2822e2ade8773a&key=2e2e8602b6d835ccf10ee56a9a7d91a2'
    },
    'CRE': {
        'name': '創世電視',
        'license': 'adef00c5ba927d01642b1e6f3cedc9fb:b45d912fec43b5bbd418ea7ea1fbcb60',
        'logo': 'https://upload.wikimedia.org/wikipedia/zh/9/91/Creation-tv_logo.png',
        'license_key': 'https://vercel-php-clearkey-hex-base64-json.vercel.app/api/results.php?keyid=adef00c5ba927d01642b1e6f3cedc9fb&key=b45d912fec43b5bbd418ea7ea1fbcb60'
    },
     'EVT1': {
        'name': 'myTV SUPER直播足球1台',
        'license': 'e8ca7903e25450d85cb32b3057948522:d5db5c03608f5f6c8a382c6abcb829e4',
        'logo': 'https://raw.githubusercontent.com/sparkssssssssss/epg/main/logo/黄金翡翠台.png',
        'license_key': 'https://vercel-php-clearkey-hex-base64-json.vercel.app/api/results.php?keyid=e8ca7903e25450d85cb32b3057948522&key=d5db5c03608f5f6c8a382c6abcb829e4'
   }
};

const API_TOKEN = 'YOUR_API_TOKEN_HERE';

async function getMytvsuper(channel) {
    if (!CHANNEL_LIST[channel]) {
        return '频道代号错误';
    }

    const headers = {
        'Accept': 'application/json',
        'Authorization': `Bearer ${API_TOKEN}`,
        'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
        'Host': 'user-api.mytvsuper.com',
        'Origin': 'https://www.mytvsuper.com',
        'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.5.2 Safari/605.1.15',
        'X-Forwarded-For': '210.6.4.148'
    };

    const params = new URLSearchParams({
        'platform': 'android_tv',
        'network_code': channel
    });

    const url = `https://user-api.mytvsuper.com/v1/channel/checkout?${params.toString()}`;

    const response = await fetch(url, { headers });

    if (!response.ok) {
        return '请求失败';
    }

    const responseJson = await response.json();
    const profiles = responseJson.profiles || [];

    let playUrl = '';
    for (const profile of profiles) {
        if (profile.quality === 'high') {
            playUrl = profile.streaming_path || '';
            break;
        }
    }

    if (!playUrl) {
        return '未找到播放地址';
    }

    playUrl = playUrl.split('&p=')[0];

    const licenseKey = CHANNEL_LIST[channel].license_key;
    const channelName = CHANNEL_LIST[channel].name;
    const channelLogo = CHANNEL_LIST[channel].logo;

    let m3uContent = `#EXTINF:-1 tvg-id="${channel}" tvg-logo="${channelLogo}",${channelName}\n`;
    m3uContent += '#KODIPROP:inputstream.adaptive.manifest_type=mpd\n';
    m3uContent += '#KODIPROP:inputstream.adaptive.license_type=clearkey\n';
    m3uContent += `#KODIPROP:inputstream.adaptive.license_key=${licenseKey}\n`;
    m3uContent += `${playUrl}\n`;

    return m3uContent;
}

async function handleRequest(request) {
    let m3uFileContent = '#EXTM3U url-tvg="https://xmltv.bph.workers.dev"\n';

    for (const channelCode of Object.keys(CHANNEL_LIST)) {
        const m3uContent = await getMytvsuper(channelCode);
        m3uFileContent += m3uContent;
    }

    return new Response(m3uFileContent, {
        headers: { 'Content-Type': 'text/plain;charset=UTF-8' }
    });
}

addEventListener('fetch', event => {
    event.respondWith(handleRequest(event.request));
});

Cloudflare Workers 代码,自行替换 'YOUR_API_TOKEN_HERE'

@coding Cloudflare Workers 新部署代码值得推荐 TOKEN 可以用变量方式保存保护隐私。

24 楼 已删除
bsex 回复

有道理,这是个简单的 demo,我后面会集成到 pixman docker 镜像上

昨天一天都是正常的,今天显示 403 拒绝访问了,怎么办哦

JIMKUN 回复

我试了下前几天部署的 Workers,正常。

JIMKUN 回复

TiviMate 源那里设置为每次启动时更新没有?

bsex 回复

原来如此谢谢了,用的试用版没有自动更新功能。

30 楼 已删除

感谢分享,我给修改一下,实现免翻直接看。

这些 mpd 源的视频流本身没有被墙,但是解密的 key 所在的域名是 vercel-php-clearkey-hex-base64-json.vercel.app 这边被屏蔽,所以,只要反代这个接口就可以实现播放。

首先去准备一个 php,用来反代 key 的文本

<?php
$url = $_GET['url'] ?? '';
if (strpos($url, 'http') !== 0) {
        $url = base64_decode($url);
    }
$html_code = pachongbo($url);
echo $html_code;
function pachongbo($url){
    $headers = [
    'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36'];

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_TIMEOUT, 100);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    $data = curl_exec($ch);
    curl_close($ch);
    return $data; 
}       
?>

php 存放在海外服务器中,接着上面那份 python 代码我修改如下

原来代码中的

m3uContent += `#KODIPROP:inputstream.adaptive.license_key=${licenseKey}\n`;

修改为

m3u_content += f"#KODIPROP:inputstream.adaptive.license_key=http://【你自己的服务器ip】/【上面那个php代码】.php?url=" +  base64.b64encode(
                        license_key.encode('utf-8')).decode('utf-8')   + "\n"

此目的为反代 key

再把上面的程序主体部分,定义为一个循环函数,接着让这个函数每 2 小时运行一次,或者你可以自己修改。

def pachongbo():
    # 创建或打开文件用于写入
    with open('mytvfree.m3u', 'w', encoding='utf-8') as m3u_file:
        # 写入 M3U 文件的头部
        m3u_file.write("#EXTM3U url-tvg=\"http://【你自己的服务器ip】/【上面那个php代码】.php?url=https://xmltv.bph.workers.dev\"\n")

        # 遍历所有频道并写入每个频道的 M3U 内容
        for channel_code in CHANNEL_LIST.keys():
            m3u_content = get_mytvsuper(channel_code)
            m3u_file.write(m3u_content)

    print("所有频道的 M3U 播放列表已生成并保存为 'mytvfree.m3u'")

while True:
    pachongbo()
    time.sleep(7200)  #2小时*60分钟*60秒  

等 mytvsuper 加入 docker

magicluweibo 回复

高手 点赞

jason 回复

哪个版本的 ott 能看?

35 楼 已删除

我正版的 tivimeta,也无法播放 mytv 的全部频道,日怪了!!!影视也无法播放,看来只能用 ott 了……

37 楼 已删除
magicluweibo 回复

不用反代,直接根据 API 接口返回的内容替换 key(如果这个 key 永远不变),或者在 github 复刻 https://github.com/samleong123/vercel-php-clearkey-hex-base64-json 这个项目然后 vercel 部署一次加自定义域名就行,worker 代码也替换掉链接就行。

catshark 回复

可以给个 demo 嘛

coding 回复

他代码里面例如翡翠台的是

'license_key': 'https://vercel-php-clearkey-hex-base64-json.vercel.app/api/results.php?keyid=0958b9c657622c465a6205eb2252b8ed&key=2d2fd7b1661b1e28de38268872b48480'

你访问这个 vercel 搭建的接口之后,得到的内容是

{ "keys":[ { "kty":"oct", "k":"/BRncamwlvxMtX/+dphhvg", "kid":"LARfWtsm05HMQc0B8AQW+g" } ], "type":"temporary" }

直接全部频道一个个换就行了,就不用走这个接口了

eyou 回复

以下观点更新:经过测试暂时不清楚是否为 worker 被墙所致

====

另外是,你代码里面提供的 EPG,我今天(2024 年 6 月 10 日 12:15:16)用 OTT 发现部分频道读不出 EPG,放在浏览器里面显示 XML 代码有误,搜索发现出现错误的地方是节目名有个字符“&”,疑似是没有做处理

浏览器报错: This page contains the following errors: error on line 269 at column 22: xmlParseEntityRef: no name Below is a rendering of the page up to the first error.

该行内容:

<title>Kiki & Nuna 知識寶庫[粵/普]</title>
catshark 回复

哦哦,你的意思是 tivimate 不支持下面这种写法是吗?

#KODIPROP:inputstream.adaptive.license_type=clearkey
#KODIPROP:inputstream.adaptive.license_key=e8ca7903e25450d85cb32b3057948522:d5db5c03608f5f6c8a382c6abcb829e4
coding 回复

原版 workerjs 是返回 302 状态码和 TVB 的视频 URL,但 tivi 不支持 302 跳转,所以只能获取直链

谢谢分享!

需要 登录 后方可回复, 如果你还没有账号请 注册新账号