Files
xwlb/main.py
T
simon 60f8c263f2 《新闻联播》每日抓取入库:全链路 + 可移植化 + 定时任务
从 CCTV 主页抓取《新闻联播》,下载 → 转 MP3/WAV → 静音切分 → ASR 识别
→ LLM 校对 → 切分为单条新闻 → 入库 MySQL。

主要内容:
- 全链路:getVideo5 抓取下载、audioRead 转写、deepseek 校对与切分、newsProcess 入库
- 可移植化:配置分层,.env 只放密钥、config.yml 放模型/接入点/路由/参数
- 可换供应商:endpoints(kind/base_url/api_key_env/extra_body)+ routes 按环节选路
- 数据保真:数值事实守卫,校对改动数字/年份/届次则整片回退 ASR 原文;
  识别不完整不发布该日精编,避免半天内容被当成完整一天
- 定时任务:systemd 每天 21:00,失败 21:30 / 22:00 重试;
  只缺切分时只重跑切分(省掉全部 ASR),用 state/.asr_complete_* 标记判定阶段
- 隧道自愈:13306 不通时自动执行 autossh.sh(所有入口共用,systemd 托管时只等待)
- 中间产物每日清理;97 项离线自检(配置/清理/事实守卫/解析/隧道)
2026-09-25 11:17:46 +08:00

25 lines
927 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""每日入口:抓取当天《新闻联播》并完成识别、切分、入库、清理中间产物
定时任务用法: python main.py (systemd 见 systemd/xwlb-daily.timer)
指定日期用法: python getVideo5.py 20260904 20260904
退出码:0 = 当天全链路成功;1 = 失败(抓不到链接 / 识别或切分失败),供重试判断。
"""
import logging
import sys
from datetime import datetime
import config
from getVideo5 import process_videos
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
if __name__ == '__main__':
# 获取当日日期并格式化为 yyyymmdd
today = datetime.now().strftime('%Y%m%d')
config.log_summary()
summary = process_videos(today, today)
if summary and summary['ok'] > 0 and summary['failed'] == 0:
sys.exit(0)
logging.error(f"❌ 当日任务失败: {summary}")
sys.exit(1)