运行商的电视盒子用起来比较繁琐需要切换还要单独的遥控器,给老人使用时使用体验远不如使用直播软件。广电去年的一些操作直播软件基本都死了,偶尔放出来的存活周期也都很短。 famingming 被停了以后, YueChan的源还算高速且稳定但是只支持ipv6,一直没有遇到合适的直播源,原想通过iptv盒子自己抓,看了下所有的设备都是单网口只好作罢。自己本地搭个肥羊的LiveRedirect,使用起来比较丝滑这里做个记录。
pixman上的使用说明
没有国内的vps,就不考虑在现有的vps上搭了,在常年开机的win主机上搭也是个不错的选择,多开一个服务而已。
环境介绍
- win10: 作为主机使用,可以根据自己情况选择,支持docker就行;
- docker desktop: docker就自行安装了,网上一堆教程;
- pixman: 服务本体;
- allinone (有需要了安装,这里不做介绍了,步骤基本一致)
- coplar: 用来做傻瓜式的内网穿透
- cloudflare workers: 需要托管的有个域名
- 油猴
步骤
安装docker
我这里使用了Docker Desktop,一键安装;安装并启动pixman
Docker Desktop里安装或者使用命令行docker pull pixman/pixman
安装均可;
运行:docker run -d --name=pixman -p 5000:5000 pixman/pixman
,第一个端口号按需修改;
更新pximan:1
2
3
4
5
6
7
8
9
10
11
12
13
14# 停止目前正在运行的容器
docker stop pixman
# 删除目前正在运行的容器
docker rm pixman
# 删除旧的镜像
docker rmi pixman/pixman
# 重新拉取最新的镜像
docker pull pixman/pixman
# 运行最新的镜像
docker run -d --name=pixman -p 5000:5000 --restart=always pixman/pixman支持直播源 :
1
2
3
4
5
6
7
8四季線上 4GTV (http://ip:port/4gtv.m3u)
江苏移动魔百盒 TPTV (http://ip:port/tptv.m3u 或 http://ip:port/tptv_proxy.m3u)
央视频直播源 (http://ip:port/ysp.m3u)
YouTube 直播源 (http://ip:port/youtube/{VIDEO_ID})
MytvSuper 直播源 (http://ip:port/mytvsuper.m3u)
Beesport 直播源 (http://ip:port/beesport.m3u)
中国移动 iTV 平台 (http://ip:port/itv.m3u 或 http://ip:port/itv_proxy.m3u)
TheTV (http://ip:port/thetv.m3u)根据自己的网络环境,配置需要代理的规则;
itv需要配置dns映射,itv_proxy不需要。
根据情况配置,需要将 ott域名 映射到 dnsany域名:
host
1
2
3
4
539.135.227.76 cache.ott.ystenlive.itv.cmvideo.cn
39.135.122.181 cache.ott.bestlive.itv.cmvideo.cn
39.135.122.175 cache.ott.wasulive.itv.cmvideo.cn
39.136.29.106 cache.ott.fifalive.itv.cmvideo.cn
39.136.247.206 cache.ott.hnbblive.itv.cmvideo.cnSurge
1
2
3
4
5
6[Host]
cache.ott.ystenlive.itv.cmvideo.cn = pixman.io.ystenlive.dnsany.com
cache.ott.bestlive.itv.cmvideo.cn = pixman.io.bestlive.dnsany.com
cache.ott.wasulive.itv.cmvideo.cn = pixman.io.wasulive.dnsany.com
cache.ott.fifalive.itv.cmvideo.cn = pixman.io.fifalive.dnsany.com
cache.ott.hnbblive.itv.cmvideo.cn = pixman.io.hnbblive.dnsany.comshadowrocket
1
2
3
4
5
6[host]
cache.ott.ystenlive.itv.cmvideo.cn = pixman.io.ystenlive.dnsany.com
cache.ott.bestlive.itv.cmvideo.cn = pixman.io.bestlive.dnsany.com
cache.ott.wasulive.itv.cmvideo.cn = pixman.io.wasulive.dnsany.com
cache.ott.fifalive.itv.cmvideo.cn = pixman.io.fifalive.dnsany.com
cache.ott.hnbblive.itv.cmvideo.cn = pixman.io.hnbblive.dnsany.comopenwrt
openwrt如果使用openClash可以直接配置 域名映射域名,否则只能修改host将ott映射到dnsany的ip,注意dnsany是定时同步移动的ott cdn列表,所以是动态的,这样就导致host需要动态维护。这里写了一个定时脚本来动态更新itvhosts文件,在dnsmap中添加hosts路径
etc/itvhosts
itvhosts.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# 定义需要解析的域名和对应的缓存域名
DOMAINS="pixman.io.ystenlive.dnsany.com pixman.io.bestlive.dnsany.com pixman.io.wasulive.dnsany.com pixman.io.fifalive.dnsany.com pixman.io.hnbblive.dnsany.com"
CACHE_DOMAINS="cache.ott.ystenlive.itv.cmvideo.cn cache.ott.bestlive.itv.cmvideo.cn cache.ott.wasulive.itv.cmvideo.cn cache.ott.fifalive.itv.cmvideo.cn cache.ott.hnbblive.itv.cmvideo.cn"
# 输出文件路径(仓库根目录下)
OUTPUT_FILE="etc/itvhosts"
# 清空文件内容
: > "$OUTPUT_FILE"
# 获取当前时间并写入文件开头作为时间戳
echo "# Updated on: $(date)" >> "$OUTPUT_FILE"
# 将字符串转化为数组形式进行遍历
i=0
for DOMAIN in $DOMAINS; do
CACHE_DOMAIN=$(echo $CACHE_DOMAINS | cut -d ' ' -f $((i+1)))
# 解析域名并提取IPv4地址
nslookup_result=$(nslookup "$DOMAIN" 2>/dev/null)
# 删除前三行并提取 IPv4 地址
IP=$(echo "$nslookup_result" | sed '1,3d' | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | head -n 1)
# 检查IP是否为空
if [ -n "$IP" ]; then
# 写入到文件中
echo "$IP $CACHE_DOMAIN" >> "$OUTPUT_FILE"
echo "Written to file: $IP $CACHE_DOMAIN"
else
echo "No IPv4 address found for domain: $DOMAIN"
fi
i=$((i + 1))
done
echo "itvhosts已更新"需要配置itvhosts.sh每隔6小时更新一次和开机运行
- itvhosts.sh 路径:
etc/init.d/myscript/
- 系统-计划任务
0 */6 * * * etc/init.d/myscript/itvhosts.sh
- 系统-启动项-本地启动脚本
愿意使用ssh配置的更方便,也可以使用捷径通过配置ssh来控制更新。
github action
如果还有其他设备也需要hosts方式配置,可以使用github action运行脚本来生成itvhosts文件,便于引用。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74name: process itvhosts
on:
schedule:
- cron: '0 */6 * * *' # 每6小时运行一次
workflow_dispatch:
jobs:
update_hosts:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Update DNS records and hosts file
run: |
set -x # 启用调试模式
# 定义 DNS 名称和对应的 host 文件内容
DNS_NAMES=(
'pixman.io.ystenlive.dnsany.com'
'pixman.io.bestlive.dnsany.com'
'pixman.io.wasulive.dnsany.com'
'pixman.io.fifalive.dnsany.com'
'pixman.io.hnbblive.dnsany.com'
)
HOSTS_MAPPING=(
'cache.ott.ystenlive.itv.cmvideo.cn'
'cache.ott.bestlive.itv.cmvideo.cn'
'cache.ott.wasulive.itv.cmvideo.cn'
'cache.ott.fifalive.itv.cmvideo.cn'
'cache.ott.hnbblive.itv.cmvideo.cn'
)
# 清空之前的 itvhosts 文件
echo "Clearing previous itvhosts file..."
> itvhosts
# 解析 DNS 记录并更新 hosts 文件
for i in "${!DNS_NAMES[@]}"; do
dns_name="${DNS_NAMES[$i]}"
host="${HOSTS_MAPPING[$i]}"
echo "Resolving DNS name: $dns_name"
# 只获取第一个非CNAME的IPv4地址
ip_address=$(dig +short "$dns_name" | grep -E '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$' | head -n 1)
echo "Resolved IP address: $ip_address"
# 检查是否得到了 IP 地址
if [ -n "$ip_address" ]; then
echo "$ip_address $host" >> itvhosts
echo "Updated itvhosts file with: $ip_address $host"
else
echo "Failed to resolve $dns_name"
fi
done
- name: Stage changes # 步骤:暂存更改
run: |
echo "Staging changes..."
git config --global user.email "[email protected]"
git config --global user.name "GitHub Action"
git add itvhosts
git status
cat itvhosts # 输出 itvhosts 文件内容以检查更新
- name: Commit changes # 步骤:提交更改
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Update itvhosts
branch: main- itvhosts.sh 路径:
安装coplar并启动web服务
- 创建隧道;
协议:http
本地地址: <pixman端口号>
域名类型: 默认即可,按需配置 - 启动隧道
- 在线隧道列表中找到地址即可使用
这里建议给coplar本身创建一个隧道,便于远程管理。
- 创建隧道;
m3u直播源使用
http://localhost:5050/ysp.m3u
http://localhost:5050/itv.m3u
http://localhost:5050/4gtv.m3u
http://localhost:35455/tv.m3u
// allinone使用
localhost:端口号使用cpolar公网地址替换即可公网使用,直播源怎么在直播软件里使用这里就不再介绍了。
异常解决
配置正确无速度或者高延迟无法播放
检查DNS!!大概率是DNS问题。wifi能使用,移动网络不能使用
还是DNS问题,修改DNScpolar公网地址变动频繁
升级订阅版解决。当然更好的方案是配置 内网穿透,或者部署在云服务器上。
[当然我接下来也提供一套免费的实现方案]:我这里使用了搭个cloudflare workers来实现url转发,解决多设备的配置问题。itv不可用
要检查是否做了域名到域名的映射,或者配置了对应的hosts4Gtv不可用
4Gtv需要配置代理1
2DOMAIN-SUFFIX,4gtv.tv,proxy
DOMAIN-SUFFIX,hinet.net,proxy
以下仅供愿意折腾的参考:
搞的越来越复杂了,进阶版按需折腾,没太大用途,大致情况先介绍下:
- 直播服务搭建: 在本地主机上(各种主机都可以,本地电脑也可以)使用Docker搭建直播服务 pixman 或者 LiveRedirect;
- 内网穿透: 使用cpolar等内网穿透工具,将搭建在本地的直播服务开放外网访问,(云主机上部署的可以忽略);
- 域名映射[选配] : 使用itv的需要域名映射解决网络问题;[不方便配置域名映射域名的可以使用我写的一个自动更新的host文件实现]()
- 直播源整理[选配] : 这里主要整理了itv.m3u,使用了github action 配合ios捷径触发,也可以定时更新;
- 解决cpolar域名变动[选配] : 付费解决是最好的方案,我这里写了一个cloudflare worker来实现url转发,客户端配置源地址时就可以固定自定义域名了;
- 捷径或者油猴脚本实现步骤5的自动化;
完整的使用体验流程:
[定时任务]定时打开cpolar管理页面发现源失效以后在本地刷新cpolar管理页面 –> [自动触发]油猴脚本将公网ip提交到workers实现URL转发到指定域名 –> [自动触发]github action脚本拉取指定域名的itv源并进行整理更新。
捷径触发更新源格式整理和itvHosts
Cloudflare worker实现同步Cpolar公网IP
1 | addEventListener('fetch', event => { |
创建KV存储提交的公网IP
对应worker文件,KV空间命名为URL_STORAGE
,在worker设置里绑定到新建的worker为woker添加路由
放个二级域名就可以了管理页面: 自定义域名/admin
跳转地址: 自定义域名
捷径操作woker
只需要发起一个url post请求,请求体为表单
,请求体内容:url
参数配置cpolar公网ip
油猴脚本提交Cpolar公网ip到Workers 实现URL转发
【 推荐配置 】。当刷新cpolar管理页面时,自动提取最新的itv公网ip并提交到workers 自动配置url转发。
定时自动更新cpolar域名的方法
[定时任务]: 费用windows用户直接使用cron即可,这里重点介绍下windows的实现.
bat实现:使用chrome登录管理页面,调整到服务列表,在服务列表执行油猴脚本将新域名提交给works;触发github Actions执行itv更新。
1 | @echo off |
[]:
不适用CF workers进行url转发可以使用 内网穿透 ,参考在serv00上使用frp实现内网穿透的示例
// 需求基本得到解决,也算完结了就不再更新了。