AI 生成: 一个自动构建 APTV 直播源的脚本工具,每天自动更新央视、卫视、地方台频道,支持源过滤、去重和可用性检测。

This commit is contained in:
admin
2026-09-28 22:26:11 +08:00
commit 7a6618e546
11 changed files with 351 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
"""从 sources 目录读取直播源"""
import os
def load_sources(sources_dir):
"""读取 sources 目录下所有 .txt 文件,返回 (category, name, url) 列表"""
channels = []
if not os.path.isdir(sources_dir):
return channels
for filename in sorted(os.listdir(sources_dir)):
if not filename.endswith(".txt"):
continue
category = filename[:-4]
filepath = os.path.join(sources_dir, filename)
with open(filepath, "r", encoding="utf-8") as f:
for line in f:
line = line.strip()
if not line or line.startswith("#"):
continue
if "," not in line:
continue
name, url = line.split(",", 1)
name = name.strip()
url = url.strip()
if name and url:
channels.append({
"category": category,
"name": name,
"url": url,
})
return channels