Skip to content

Commit f7e0704

Browse files
committed
Update code to version 1.3.8
1 parent 2c2d5ff commit f7e0704

7 files changed

Lines changed: 623 additions & 0 deletions

1.3.8/Dockerfile

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
FROM debian:bullseye-slim
2+
3+
# 设置工作目录
4+
WORKDIR /app
5+
6+
# 安装 Python、pip 和 cron
7+
RUN apt-get update && apt-get install -y python3 python3-pip cron
8+
9+
# 安装所需的 Python 库
10+
RUN pip3 install schedule requests
11+
12+
# 使用官方 Node.js 镜像作为基础镜像
13+
FROM node:16
14+
15+
# 安装 Python、pip 和 cron
16+
RUN apt-get update && apt-get install -y python3 python3-pip cron
17+
18+
# 安装所需的 Python 库
19+
RUN pip3 install requests beautifulsoup4 schedule
20+
21+
# 设置工作目录
22+
WORKDIR /app
23+
24+
# 复制 package.json 和 package-lock.json(如果存在)
25+
COPY package*.json ./
26+
27+
# 安装 Node.js 依赖
28+
RUN npm install
29+
RUN npm list node-fetch
30+
31+
RUN npm install node-fetch@2.6.7 lru-cache xmldom
32+
# 或者使用 yarn
33+
# RUN yarn add node-fetch@2.6.7 lru-cache xmldom
34+
35+
# 复制所有源代码到容器中
36+
COPY . .
37+
38+
# 设置 cron 任务
39+
RUN echo "0 5,17 * * * python3 /app/convert_mytvfree.py" > /etc/cron.d/mytvfree-cron
40+
RUN chmod 0644 /etc/cron.d/mytvfree-cron
41+
RUN crontab /etc/cron.d/mytvfree-cron
42+
43+
# 创建启动脚本
44+
RUN echo "#!/bin/sh" > /app/start.sh
45+
RUN echo "cron" >> /app/start.sh
46+
RUN echo "python3 /app/convert_mytvfree.py &" >> /app/start.sh
47+
RUN echo "node index.js" >> /app/start.sh
48+
RUN chmod +x /app/start.sh
49+
50+
# 暴露端口
51+
EXPOSE 4994
52+
53+
# 启动命令
54+
CMD ["/app/start.sh"]

1.3.8/convert_mytvfree.py

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
import requests
2+
import json
3+
4+
CHANNEL_LIST = {
5+
'J': {
6+
'name': '翡翠台',
7+
'license': '0958b9c657622c465a6205eb2252b8ed:2d2fd7b1661b1e28de38268872b48480',
8+
'logo': 'https://github.com/wanglindl/TVlogo/blob/main/img/TVB1.png?raw=true',
9+
'license_key': 'https://vercel-php-clearkey-hex-base64-json.vercel.app/api/results.php?keyid=0958b9c657622c465a6205eb2252b8ed&key=2d2fd7b1661b1e28de38268872b48480'
10+
},
11+
'JUHD': {
12+
'name': '翡翠台 4K',
13+
'license': '2c045f5adb26d391cc41cd01f00416fa:fc146771a9b096fc4cb57ffe769861be',
14+
'logo': 'https://github.com/wanglindl/TVlogo/blob/main/img/TVB1.png?raw=true',
15+
'license_key': 'https://vercel-php-clearkey-hex-base64-json.vercel.app/api/results.php?keyid=2c045f5adb26d391cc41cd01f00416fa&key=fc146771a9b096fc4cb57ffe769861be'
16+
},
17+
'B': {
18+
'name': 'TVBplus',
19+
'license': '56603b65fa1d7383b6ef0e73b9ae69fa:5d9d8e957d2e45d8189a56fe8665aaaa',
20+
'logo': 'https://raw.githubusercontent.com/wanglindl/TVlogo/main/img/TVB3.png',
21+
'license_key': 'https://vercel-php-clearkey-hex-base64-json.vercel.app/api/results.php?keyid=56603b65fa1d7383b6ef0e73b9ae69fa&key=5d9d8e957d2e45d8189a56fe8665aaaa'
22+
},
23+
'P': {
24+
'name': '明珠台',
25+
'license': 'e04facdd91354deee318c674993b74c1:8f97a629de680af93a652c3102b65898',
26+
'logo': 'https://github.com/wanglindl/TVlogo/blob/main/img/TVB1.png?raw=true',
27+
'license_key': 'https://vercel-php-clearkey-hex-base64-json.vercel.app/api/results.php?keyid=e04facdd91354deee318c674993b74c1&key=8f97a629de680af93a652c3102b65898'
28+
},
29+
'CWIN': {
30+
'name': 'Super Free',
31+
'license': '0737b75ee8906c00bb7bb8f666da72a0:15f515458cdb5107452f943a111cbe89',
32+
'logo': 'https://raw.githubusercontent.com/sparkssssssssss/epg/main/logo/黄金翡翠台.png',
33+
'license_key': 'https://vercel-php-clearkey-hex-base64-json.vercel.app/api/results.php?keyid=0737b75ee8906c00bb7bb8f666da72a0&key=15f515458cdb5107452f943a111cbe89'
34+
},
35+
'TVG': {
36+
'name': '黄金翡翠台',
37+
'license': '8fe3db1a24969694ae3447f26473eb9f:5cce95833568b9e322f17c61387b306f',
38+
'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',
39+
'license_key': 'https://vercel-php-clearkey-hex-base64-json.vercel.app/api/results.php?keyid=8fe3db1a24969694ae3447f26473eb9f&key=5cce95833568b9e322f17c61387b306f'
40+
},
41+
'C': {
42+
'name': '无线新闻台',
43+
'license': '90a0bd01d9f6cbb39839cd9b68fc26bc:51546d1f2af0547f0e961995b60a32a1',
44+
'logo': 'https://raw.githubusercontent.com/wanglindl/TVlogo/main/img/TVB4.png',
45+
'license_key': 'https://vercel-php-clearkey-hex-base64-json.vercel.app/api/results.php?keyid=90a0bd01d9f6cbb39839cd9b68fc26bc&key=51546d1f2af0547f0e961995b60a32a1'
46+
},
47+
'CTVE': {
48+
'name': '娱乐新闻台',
49+
'license': '6fa0e47750b5e2fb6adf9b9a0ac431a3:a256220e6c2beaa82f4ca5fba4ec1f95',
50+
'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',
51+
'license_key': 'https://vercel-php-clearkey-hex-base64-json.vercel.app/api/results.php?keyid=6fa0e47750b5e2fb6adf9b9a0ac431a3&key=a256220e6c2beaa82f4ca5fba4ec1f95'
52+
},
53+
'PCC': {
54+
'name': '凤凰卫视中文台',
55+
'license': '7bca0771ba9205edb5d467ce2fdf0162:eb19c7e3cea34dc90645e33f983b15ab',
56+
'logo': 'https://raw.githubusercontent.com/wanglindl/TVlogo/main/img/Phoenix1.png',
57+
'license_key': 'https://vercel-php-clearkey-hex-base64-json.vercel.app/api/results.php?keyid=7bca0771ba9205edb5d467ce2fdf0162&key=eb19c7e3cea34dc90645e33f983b15ab'
58+
},
59+
'PIN': {
60+
'name': '凤凰卫视资讯台',
61+
'license': '83f7d313adfc0a5b978b9efa0421ce25:ecdc8065a46287bfb58e9f765e4eec2b',
62+
'logo': 'https://raw.githubusercontent.com/wanglindl/TVlogo/main/img/Phoenix2.png',
63+
'license_key': 'https://vercel-php-clearkey-hex-base64-json.vercel.app/api/results.php?keyid=83f7d313adfc0a5b978b9efa0421ce25&key=ecdc8065a46287bfb58e9f765e4eec2b'
64+
},
65+
'PHK': {
66+
'name': '凤凰卫视香港台',
67+
'license': 'cde62e1056eb3615dab7a3efd83f5eb4:b8685fbecf772e64154630829cf330a3',
68+
'logo': 'https://raw.githubusercontent.com/wanglindl/TVlogo/main/img/Phoenix3.png',
69+
'license_key': 'https://vercel-php-clearkey-hex-base64-json.vercel.app/api/results.php?keyid=cde62e1056eb3615dab7a3efd83f5eb4&key=b8685fbecf772e64154630829cf330a3'
70+
},
71+
'EVT1': {
72+
'name': 'myTV SUPER直播足球1台',
73+
'license': 'e8ca7903e25450d85cb32b3057948522:d5db5c03608f5f6c8a382c6abcb829e4',
74+
'logo': 'https://raw.githubusercontent.com/sparkssssssssss/epg/main/logo/黄金翡翠台.png',
75+
'license_key': 'https://vercel-php-clearkey-hex-base64-json.vercel.app/api/results.php?keyid=e8ca7903e25450d85cb32b3057948522&key=d5db5c03608f5f6c8a382c6abcb829e4'
76+
}
77+
}
78+
79+
def get_mytvsuper(channel):
80+
if channel not in CHANNEL_LIST:
81+
return '频道代号错误'
82+
83+
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' # 请自行获取
84+
headers = {
85+
'Accept': 'application/json',
86+
'Authorization': 'Bearer ' + api_token,
87+
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
88+
'Host': 'user-api.mytvsuper.com',
89+
'Origin': 'https://www.mytvsuper.com',
90+
'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',
91+
'Referer': 'https://www.mytvsuper.com/',
92+
'X-Forwarded-For': '210.6.4.148' # 香港原生IP 210.6.4.148
93+
}
94+
95+
params = {
96+
'platform': 'android_tv',
97+
'network_code': channel
98+
}
99+
100+
url = 'https://user-api.mytvsuper.com/v1/channel/checkout'
101+
response = requests.get(url, headers=headers, params=params)
102+
103+
if response.status_code != 200:
104+
return '请求失败'
105+
106+
response_json = response.json()
107+
profiles = response_json.get('profiles', [])
108+
109+
play_url = ''
110+
for profile in profiles:
111+
if profile.get('quality') == 'high':
112+
play_url = profile.get('streaming_path', '')
113+
break
114+
115+
if not play_url:
116+
return '未找到播放地址'
117+
118+
play_url = play_url.split('&p=')[0]
119+
120+
license_key = CHANNEL_LIST[channel]['license_key']
121+
channel_name = CHANNEL_LIST[channel]['name']
122+
channel_logo = CHANNEL_LIST[channel]['logo']
123+
m3u_content = f"#EXTINF:-1 tvg-id=\"{channel}\" tvg-logo=\"{channel_logo}\",{channel_name}\n"
124+
m3u_content += "#KODIPROP:inputstream.adaptive.manifest_type=mpd\n"
125+
m3u_content += "#KODIPROP:inputstream.adaptive.license_type=clearkey\n"
126+
m3u_content += f"#KODIPROP:inputstream.adaptive.license_key={license_key}\n"
127+
m3u_content += f"{play_url}\n"
128+
129+
return m3u_content
130+
131+
# 创建或打开文件用于写入
132+
with open('mytvfree.m3u', 'w', encoding='utf-8') as m3u_file:
133+
# 写入 M3U 文件的头部
134+
m3u_file.write("#EXTM3U url-tvg=\"https://xmltv.bph.workers.dev\"\n")
135+
136+
# 遍历所有频道并写入每个频道的 M3U 内容
137+
for channel_code in CHANNEL_LIST.keys():
138+
m3u_content = get_mytvsuper(channel_code)
139+
m3u_file.write(m3u_content)
140+
141+
print("所有频道的 M3U 播放列表已生成并保存为 'mytvfree.m3u'。")

1.3.8/crontab

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Run the script every day at 5AM and 5PM
2+
0 5,17 * * * python3 /app/convert_mytvfree.py >> /var/log/cron.log 2>&1
3+

0 commit comments

Comments
 (0)