Sync all projects
This commit is contained in:
@@ -55,7 +55,6 @@ CGTN俄语,
|
||||
CGTN法语,
|
||||
CGTN西语,
|
||||
CGTN阿语,
|
||||
CGTN,
|
||||
直播中国,
|
||||
|
||||
|
||||
|
||||
@@ -5844,3 +5844,212 @@ Bella贝拉酱,
|
||||
我们可爱的程程,
|
||||
正宗吔汁吔树牌,
|
||||
动漫唯美風,
|
||||
|
||||
# 以下 198 个频道为其他任务未匹配到的频道,自动追加于 2026-07-09 08:28:59.276023
|
||||
央视,#genre#
|
||||
中国天气,
|
||||
卫视,#genre#
|
||||
南方卫视,
|
||||
黄河卫视,
|
||||
数字,#genre#
|
||||
NewTV 精品记录,
|
||||
NewTV 武搏世界,
|
||||
怡伴健康,
|
||||
中国功夫,
|
||||
欢乐剧场,
|
||||
财富天下,
|
||||
浙江,#genre#
|
||||
浙江钱江都市,
|
||||
浙江钱江台,
|
||||
杭州西湖明珠,
|
||||
宁波TV5,
|
||||
宁波电视台1套,
|
||||
宁波电视台2套,
|
||||
宁波电视台3套,
|
||||
宁波电视台4套,
|
||||
宁波4套影视,
|
||||
NBTV1|NBTV-1,
|
||||
NBTV2|NBTV-2,
|
||||
NBTV3|NBTV-3,
|
||||
NBTV4|NBTV-4,
|
||||
丽水公共,
|
||||
衢州公共,
|
||||
衢州新闻综合,
|
||||
金华教育科技,
|
||||
金华新闻综合,
|
||||
金华公共,
|
||||
温州新闻综合,
|
||||
浙江民生休闲,
|
||||
浙江松阳,
|
||||
浙江教科影院,
|
||||
浙江龙泉,
|
||||
镇海先锋影院,
|
||||
金华都市农村,
|
||||
象山电视台新闻综合,
|
||||
舟山群岛旅游,
|
||||
舟山公共生活,
|
||||
温州都市生活,
|
||||
温州经济科教,
|
||||
淳安电视台,
|
||||
海宁生活服务,
|
||||
桐庐综合,
|
||||
桐乡新闻综合,
|
||||
德清新闻综合,
|
||||
德清文化生活,
|
||||
北仑电视台,
|
||||
舟山新闻综合,
|
||||
浙江新闻,
|
||||
浙江国际,
|
||||
浙江少儿,
|
||||
浙江教科,
|
||||
之江纪录,
|
||||
浙江民生,
|
||||
浙江钱江|钱江频道,
|
||||
公共新闻,
|
||||
上虞新闻综合,
|
||||
上虞文化影院,
|
||||
上虞新商都,
|
||||
云和新闻综合,
|
||||
兰溪新闻综合,
|
||||
平湖新闻综合,
|
||||
开化新闻综合,
|
||||
开化国家公园,
|
||||
普陀新闻综合,
|
||||
永嘉新闻综合,
|
||||
绍兴文化影视,
|
||||
绍兴新闻综合,
|
||||
苍南新闻综合,
|
||||
萧山生活频道|萧山生活,
|
||||
诸暨新闻综合,
|
||||
青田电视台,
|
||||
龙游生活娱乐,
|
||||
衢江新闻综合,
|
||||
浙江生活,
|
||||
浙江教育,
|
||||
杭州综合,
|
||||
杭州明珠,
|
||||
杭州生活,
|
||||
杭州影视,
|
||||
嘉兴新闻综合,
|
||||
湖州公共,
|
||||
湖州新闻综合,
|
||||
湖州文化娱乐,
|
||||
浙江留学,
|
||||
浙江数码时代,
|
||||
浙江青田,
|
||||
浙江遂昌,
|
||||
遂昌综合,
|
||||
缙云综合,
|
||||
缙云新闻综合,
|
||||
绍兴电视台公共,
|
||||
绍兴文化影院,
|
||||
绍兴公共,
|
||||
海宁新闻综合,
|
||||
洞头综合,
|
||||
武义新闻综合,
|
||||
松阳综合,
|
||||
新昌生活,
|
||||
新昌新闻综合,
|
||||
文成综合,
|
||||
庆元综合,
|
||||
嵊泗综合,
|
||||
余杭综合,
|
||||
余杭未来E,
|
||||
余姚综合,
|
||||
余姚姚江文化,
|
||||
中国蓝新闻,
|
||||
广东,#genre#
|
||||
广东综艺,
|
||||
广东影视,
|
||||
经济科教,
|
||||
现代教育,
|
||||
深圳卫视,
|
||||
深圳都市频道,
|
||||
深圳电视剧频道,
|
||||
深圳娱乐频道,
|
||||
深圳体育健康,
|
||||
深圳少儿频道,
|
||||
深圳公共频道,
|
||||
深圳宝安频道,
|
||||
深圳龙岗频道,
|
||||
深圳东部频道,
|
||||
深圳众创TV,
|
||||
韶关新闻综合,
|
||||
韶关绿色生活,
|
||||
湛江新闻综合,
|
||||
湛江公共,
|
||||
揭阳综合,
|
||||
揭阳生活,
|
||||
江门教育,
|
||||
HZTV-1,
|
||||
HZTV-2,
|
||||
珠海-1,
|
||||
珠海-2,
|
||||
肇庆综合,
|
||||
肇庆生活服务,
|
||||
清远新闻综合,
|
||||
清远文旅生活,
|
||||
云浮文旅,
|
||||
佛山南海,
|
||||
佛山顺德,
|
||||
中山综合,
|
||||
香山文化,
|
||||
中山教育,
|
||||
徐闻综合,
|
||||
汕头经济,
|
||||
上海,#genre#
|
||||
上海新闻,
|
||||
七彩戏剧,
|
||||
法治天地,
|
||||
港澳台,#genre#
|
||||
香港卫视,
|
||||
凤凰卫视中文台|凤凰中文|鳳凰中文,
|
||||
凤凰卫视资讯台|凤凰资讯|鳳凰資訊,
|
||||
凤凰卫视香港台|凤凰香港|鳳凰香港,
|
||||
J2|TVB J2台|TVB-Plus,
|
||||
台视新闻|台視新聞|TW台视新闻,
|
||||
澳亚卫视,
|
||||
Astro AEC,
|
||||
爱奇艺,
|
||||
地方,#genre#
|
||||
东阳影视生活,
|
||||
春晚,#genre#
|
||||
春晚2024年,
|
||||
春晚2023年,
|
||||
春晚2022年,
|
||||
春晚2021年,
|
||||
春晚2020年,
|
||||
春晚2019年,
|
||||
春晚2018年,
|
||||
春晚2017年,
|
||||
春晚2015年,
|
||||
春晚2014年,
|
||||
春晚2013年,
|
||||
春晚2011年,
|
||||
春晚2010年,
|
||||
春晚2009年,
|
||||
春晚2008年,
|
||||
春晚2007年,
|
||||
春晚2006年,
|
||||
春晚2005年,
|
||||
春晚2004年,
|
||||
春晚2003年,
|
||||
春晚2002年,
|
||||
春晚2001年,
|
||||
春晚2000年,
|
||||
春晚1999年,
|
||||
春晚1998年,
|
||||
春晚1997年,
|
||||
春晚1996年,
|
||||
春晚1995年,
|
||||
春晚1994年,
|
||||
春晚1993年,
|
||||
春晚1992年,
|
||||
春晚1991年,
|
||||
春晚1989年,
|
||||
春晚1988年,
|
||||
春晚1987年,
|
||||
春晚1986年,
|
||||
春晚1985年,
|
||||
春晚1984年,
|
||||
春晚1983年,
|
||||
|
||||
+69
-6
@@ -849,13 +849,16 @@ def process_iptv_task(template_file, tv_urls, output_m3u, output_txt, report_fil
|
||||
"""
|
||||
处理单个IPTV任务的封装函数
|
||||
增强: 新增 all_channels 参数支持"预抓取复用",避免多任务重复请求同一批源;
|
||||
新增 extra_m3u/extra_txt,可为该任务额外产出"模板外可自动归类"的补充列表。
|
||||
新增 extra_m3u/extra_txt,可为该任务额外产出"模板外可自动归类"的补充列表;
|
||||
新增返回值 (matched, unmatched_tmpl, unmatched_src),供调用方在任务间
|
||||
传递"未匹配"数据(例如把任务1的未匹配频道追加进任务2的模板)。
|
||||
解析失败(模板不存在)时返回 (None, None, None),调用方需做空值判断。
|
||||
"""
|
||||
logger.info(f"=== 开始处理任务: {template_file} ===")
|
||||
|
||||
template = parse_template(template_file)
|
||||
if not template:
|
||||
return
|
||||
return None, None, None
|
||||
|
||||
# 增强: 若未传入预抓取数据,则自行抓取(保持向后兼容)
|
||||
if all_channels is None:
|
||||
@@ -877,6 +880,62 @@ def process_iptv_task(template_file, tv_urls, output_m3u, output_txt, report_fil
|
||||
remove_unmatched_from_template(template_file, unmatched_tmpl)
|
||||
|
||||
logger.info(f"=== 任务完成: {template_file} ===\n")
|
||||
return matched, unmatched_tmpl, unmatched_src
|
||||
|
||||
def append_unmatched_to_template(unmatched_template, target_template_file):
|
||||
"""
|
||||
新增功能: 把"任务1未匹配到的模板频道"追加进另一个模板文件(如 iptv_test.txt),
|
||||
以便后续任务继续尝试匹配 / 持续观察这些频道后续是否恢复可用。
|
||||
|
||||
设计要点:
|
||||
- 幂等: 已存在于目标模板对应分类下的频道不会被重复追加,可放心多次运行脚本
|
||||
- 目标文件不存在时自动创建
|
||||
- 追加时保留原始频道名写法(含 "变体1|变体2" 语法),不做任何改写,
|
||||
确保后续 match_channels 的匹配行为与来源模板完全一致
|
||||
- 复用 parse_template "同一分类可重复出现、不清空之前频道" 的既有特性,
|
||||
直接在文件末尾新增一段 "分类,#genre#" 块,无需就地插入编辑
|
||||
|
||||
返回本次实际追加的频道数量(0 表示无需追加)。
|
||||
"""
|
||||
total_lost = sum(len(v) for v in (unmatched_template or {}).values())
|
||||
if total_lost == 0:
|
||||
logger.info(f"任务未匹配数为 0,无需追加到 {target_template_file}")
|
||||
return 0
|
||||
|
||||
# 读取目标模板中已有的频道,避免重复追加(幂等)
|
||||
existing = parse_template(target_template_file) or OrderedDict()
|
||||
existing_sets = {cat: set(names) for cat, names in existing.items()}
|
||||
|
||||
append_lines = []
|
||||
appended_count = 0
|
||||
for cat, names in unmatched_template.items():
|
||||
# 去重且保持原始出现顺序
|
||||
unique_names = list(OrderedDict.fromkeys(names))
|
||||
new_names = [n for n in unique_names if n not in existing_sets.get(cat, set())]
|
||||
if not new_names:
|
||||
continue
|
||||
append_lines.append(f"{cat},#genre#")
|
||||
append_lines.extend(f"{n}," for n in new_names)
|
||||
appended_count += len(new_names)
|
||||
|
||||
if not appended_count:
|
||||
logger.info(f"未匹配频道均已存在于 {target_template_file},无需重复追加")
|
||||
return 0
|
||||
|
||||
try:
|
||||
ensure_dir(target_template_file)
|
||||
file_has_content = os.path.exists(target_template_file) and os.path.getsize(target_template_file) > 0
|
||||
with open(target_template_file, "a", encoding="utf-8") as f:
|
||||
if file_has_content:
|
||||
f.write("\n")
|
||||
f.write(f"# 以下 {appended_count} 个频道为其他任务未匹配到的频道,"
|
||||
f"自动追加于 {datetime.now()}\n")
|
||||
f.write("\n".join(append_lines) + "\n")
|
||||
logger.info(f"已将 {appended_count} 个未匹配频道追加进 {target_template_file}")
|
||||
return appended_count
|
||||
except Exception as e:
|
||||
logger.error(f"追加未匹配频道到 {target_template_file} 失败: {e}")
|
||||
return 0
|
||||
|
||||
if __name__ == "__main__":
|
||||
# === 配置区 ===
|
||||
@@ -897,7 +956,7 @@ if __name__ == "__main__":
|
||||
ALL_CHANNELS = fetch_all_channels(TV_URLS) if TV_URLS else OrderedDict()
|
||||
|
||||
# === 任务1: 主列表 ===
|
||||
process_iptv_task(
|
||||
_matched1, unmatched_tmpl1, _unmatched_src1 = process_iptv_task(
|
||||
template_file="py/config/iptv.txt",
|
||||
tv_urls=TV_URLS,
|
||||
output_m3u="lib/iptv.m3u",
|
||||
@@ -906,12 +965,16 @@ if __name__ == "__main__":
|
||||
auto_clean=False,
|
||||
all_channels=ALL_CHANNELS,
|
||||
# 新增: 模板外可自动归类的补充列表
|
||||
extra_m3u="lib/iptv_ext.m3u" if ENABLE_AUTOGROUP_EXTRA else None,
|
||||
extra_txt="lib/iptv_ext.txt" if ENABLE_AUTOGROUP_EXTRA else None,
|
||||
extra_m3u="lib/iptv_extra.m3u" if ENABLE_AUTOGROUP_EXTRA else None,
|
||||
extra_txt="lib/iptv_extra.txt" if ENABLE_AUTOGROUP_EXTRA else None,
|
||||
)
|
||||
|
||||
# === 任务2: 测试列表 (如果配置文件存在) ===
|
||||
# === 新增: 把任务1未匹配到的频道追加进测试列表模板,再执行任务2 ===
|
||||
TEST_TEMPLATE_FILE = "py/config/iptv_test.txt"
|
||||
if unmatched_tmpl1:
|
||||
append_unmatched_to_template(unmatched_tmpl1, TEST_TEMPLATE_FILE)
|
||||
|
||||
# === 任务2: 测试列表 (追加后必然存在,除非任务1无未匹配且此前也无测试模板文件) ===
|
||||
if os.path.exists(TEST_TEMPLATE_FILE):
|
||||
process_iptv_task(
|
||||
template_file=TEST_TEMPLATE_FILE,
|
||||
|
||||
Reference in New Issue
Block a user