Files
xwlb/systemd/xwlb-daily.service
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

31 lines
1.0 KiB
Desktop File
Raw Permalink 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.
[Unit]
Description=新闻联播每日抓取入库(下载 → 识别 → 校对 → 切分 → 入库 → 清理)
Documentation=file:///home/pi/project/xwlb/README.md
# 数据库走 autossh 隧道,隧道由独立服务托管,随本服务一起拉起
Wants=network-online.target xwlb-tunnel.service
After=network-online.target xwlb-tunnel.service
[Service]
Type=oneshot
User=pi
Group=pi
WorkingDirectory=/home/pi/project/xwlb
# 失败重试(21:30 / 22:00)在脚本内部完成,因此可能持续到 2~3 小时;
# systemd 默认 TimeoutStartSec=90s 会把服务砍掉,必须放大。
TimeoutStartSec=10800
# 成败由脚本退出码体现,不用 systemd 反复重启
Restart=no
StandardOutput=journal
StandardError=journal
SyslogIdentifier=xwlb-daily
UMask=0077
Environment=PYTHONUNBUFFERED=1
ExecStart=/home/pi/project/xwlb/scripts/run_daily.sh
# 轻量加固:只读保护系统目录,不动 $HOME(yt-dlp 需要写 ~/.cache)
NoNewPrivileges=yes
PrivateTmp=yes
ProtectSystem=full
[Install]
WantedBy=multi-user.target