整了个 iptv m3u 源的聚合 筛选工具 感觉挺有用分享下

1 月 12 日
 a707782628
因为自己来来回回只看那一两个频道,收集的十几个源就是为了从那几千个频道里来回切换,这个挂了换另一个,但是电视配置太拉胯加载不必要的频道会卡的不要不要的,所以有了这个工具

GitHub: https://github.com/XianYuDaXian/iptv-m3u-manager


界面演示

🛠 如何使用
Python 环境( 3.11+):

1. 安装:pip install -r requirements.txt
2. 运行:uvicorn main:app --host 0.0.0.0 --port 8000
3. 管理:打开浏览器访问 http://localhost:8000 即可开始配置。
2033 次点击
所在节点    分享创造
12 条回复
jamos
1 月 13 日
公网的源, 有的是移动友好的,有的是电信友好的,还有些是纯 ipv6 的, 所以线路好坏依赖自身的环境

另外看你代码好像只是检测 url 的可用性
async def check_url(url: str, session: aiohttp.ClientSession):
try:
start = datetime.now()
# Use custom UA as requested
headers = {"User-Agent": "AptvPlayer/1.4.1"}
async with session.head(url, headers=headers, timeout=5, allow_redirects=True) as response:
latency = int((datetime.now() - start).total_seconds() * 1000)
return {
"url": url,
"status": response.status < 400,
"latency": latency,
"error": None
}
except Exception as e:
return {
"url": url,
"status": False,
"latency": 0,
"error": str(e)
}


如果是 m3u8 的,latency 可能误差较大,因为文件太小了
a707782628
1 月 13 日
@jamos 我也搜过要像 iptv 软件那样握手后用 ffmpeg 检测流的分辨率状态啥的才是最准确的,但是频道一多就卡慢,类似很多源方都不推荐 aptv 或者 tivimate 上开启频道预览。所以现在还只是普通的检测 HTTP 状态码,不过加上应该也不难。
shuxge1223
1 月 13 日
这不就是盗源?
a707782628
1 月 13 日
@jamos 更新了下,用 ffmpeg 截图一帧来更精准的检测频道存活,自动禁用无效频道
a707782628
1 月 13 日
@shuxge1223 不是哥们,本来源的提供方就是让你放随便一个 iptv 软件里就能看的,我只不过是做了下筛选,哪里算得上盗
a707782628
1 月 13 日

深度检测效果图
paradislover
1 月 13 日
可以发布 docker ,布置方便些
a707782628
1 月 13 日
@paradislover 有的, 刚弄好的。
git clone https://github.com/XianYuDaXian/iptv-m3u-manager.git
cd iptv-m3u-manager
docker-compose up -d
默认访问 8000
BeiChuanAlex
1 月 13 日
完全不了解这项目,能对小白解释一下这个项目是干啥的吗
a707782628
1 月 14 日
@BeiChuanAlex 当你有多个 iptv 源但是想看的台就那么几个,但是又不想在那成千上万个频道列表里翻来翻去,就用这个来聚合跟筛选。
jamos
1 月 15 日
校验免费源这条路我也折腾过,免费的无论怎么检测,都不如意,因为意外总是发生, 记得 2024 年 9 月凤凰卫视的频道突然就都不能访问了,找了好多,都不行, 最后我是从官方网站抓取的,但是速度还是不稳定,经常卡顿

我最后是抓取了电信 itv 的组播频道转单播,港台的中文节目都是使用本地缓存 5 分钟的方式,这样才真正实现几乎告别卡顿

``` js 2024-09-22 04:05 cloudflare worker 直接代理凤凰卫视中文台
https://fhws.818000.xyz/fhwszxt 资讯台
https://fhws.818000.xyz/fhwszwt 中文台

async function handleRequest(request) {
const url = new URL(request.url);
let apiUrl = "https://api.fengshows.cn/hub/live/auth-url?live_qa=hd&live_id=7c96b084-60e1-40a9-89c5-682b994fb680";
//凤凰卫视中文台 https://api.fengshows.cn/hub/live/auth-url?live_qa=hd&live_id=f7f48462-9b13-485b-8101-7b54716411ec
//凤凰卫视资讯台 https://api.fengshows.cn/hub/live/auth-url?live_qa=hd&live_id=7c96b084-60e1-40a9-89c5-682b994fb680
if (url.pathname === '/fhwszwt') {
apiUrl = "https://api.fengshows.cn/hub/live/auth-url?live_qa=hd&live_id=f7f48462-9b13-485b-8101-7b54716411ec";
}
const response = await fetch(apiUrl);
const data = await response.json();
const liveUrl = data.data.live_url;

if (liveUrl.startsWith('http')) {
const flvResponse = await fetch(liveUrl, {
headers: {
'User-Agent': 'VLC/3.0.18 LibVLC/3.0.18'
}
});

// 检查 FLV 响应状态
if (flvResponse.ok) {
return new Response(flvResponse.body, {
headers: {
'Content-Type': 'video/x-flv',
'Content-liveUrl': liveUrl,
'Content-liveUrl2': flvResponse.status,
// 其他必要的头部,比如 Cache-Control
},
status: flvResponse.status,
});
} else {
return new Response('Failed to fetch live stream', { status: flvResponse.status });
}
} else {
return new Response('Error: Key not found', { status: 404 });
}
}

addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request));
});
```
a707782628
1 月 16 日
@jamos 只要你的源够多,那就没问题,我收集了十几个源,几万条频道,光一个翡翠台就有 2 30 个,一个挂了就换另一个

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://v2ex.ih06.com/t/1185069

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX