《新闻联播》每日抓取入库:全链路 + 可移植化 + 定时任务
从 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 项离线自检(配置/清理/事实守卫/解析/隧道)
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
[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
|
||||
@@ -0,0 +1,13 @@
|
||||
[Unit]
|
||||
Description=每天 21:00 触发《新闻联播》抓取入库(失败时脚本内 21:30 / 22:00 自动重试)
|
||||
|
||||
[Timer]
|
||||
# 每天 21:00(新闻联播 19:00 播出,21:00 页面与视频都已就绪)
|
||||
OnCalendar=*-*-* 21:00:00
|
||||
# 树莓派关机/重启错过时刻时,开机后补跑一次(不会重复:脚本内部幂等)
|
||||
Persistent=true
|
||||
AccuracySec=1s
|
||||
Unit=xwlb-daily.service
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
||||
@@ -0,0 +1,21 @@
|
||||
[Unit]
|
||||
Description=autossh 隧道:本机 127.0.0.1:13306 → doorcome.cn:3306(MySQL)
|
||||
Documentation=file:///home/pi/project/xwlb/autossh.sh
|
||||
After=network-online.target
|
||||
Wants=network-online.target
|
||||
|
||||
[Service]
|
||||
User=pi
|
||||
Group=pi
|
||||
# 让 autossh 在首次连接失败时也持续重试,而不是直接退出
|
||||
Environment=AUTOSSH_GATETIME=0
|
||||
ExecStart=/usr/bin/autossh -M 0 -N \
|
||||
-o ServerAliveInterval=30 -o ServerAliveCountMax=3 \
|
||||
-o ExitOnForwardFailure=yes \
|
||||
-L 13306:localhost:3306 tunnel@doorcome.cn
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
SyslogIdentifier=xwlb-tunnel
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Reference in New Issue
Block a user