AI 生成: 一个自动构建 APTV 直播源的脚本工具,每天自动更新央视、卫视、地方台频道,支持源过滤、去重和可用性检测。
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""APTV 直播源构建主入口"""
|
||||
|
||||
import sys
|
||||
import config
|
||||
from fetcher import load_sources
|
||||
from filter import filter_available, dedup
|
||||
from generator import generate_m3u
|
||||
|
||||
|
||||
def main():
|
||||
print("[1/4] 读取源文件...")
|
||||
channels = load_sources(config.SOURCES_DIR)
|
||||
print(f" 共读取 {len(channels)} 条源")
|
||||
|
||||
if not channels:
|
||||
print("没有可用的源,请检查 sources/ 目录")
|
||||
sys.exit(1)
|
||||
|
||||
print("[2/4] 去重...")
|
||||
if config.ENABLE_DEDUP:
|
||||
before = len(channels)
|
||||
channels = dedup(channels)
|
||||
print(f" 去重后剩余 {len(channels)} 条(移除 {before - len(channels)} 条)")
|
||||
else:
|
||||
print(" 已跳过")
|
||||
|
||||
print("[3/4] 可用性过滤...")
|
||||
if config.ENABLE_FILTER:
|
||||
before = len(channels)
|
||||
channels = filter_available(
|
||||
channels,
|
||||
timeout=config.TIMEOUT,
|
||||
max_workers=config.MAX_WORKERS,
|
||||
)
|
||||
print(f" 过滤后剩余 {len(channels)} 条(移除 {before - len(channels)} 条)")
|
||||
else:
|
||||
print(" 已跳过")
|
||||
|
||||
if not channels:
|
||||
print("没有可用源,退出")
|
||||
sys.exit(1)
|
||||
|
||||
print("[4/4] 生成 M3U...")
|
||||
count = generate_m3u(
|
||||
channels,
|
||||
config.OUTPUT_FILE,
|
||||
category_order=config.CATEGORY_ORDER,
|
||||
)
|
||||
print(f" 已生成 {config.OUTPUT_FILE},共 {count} 个频道")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user