douyinWEB/docs/SHORTS.md
eric 47d17aee3c Document YouTube groups and Shorts side-path; sync dual-platform pipeline.
Add isolated Shorts OAuth/clip/upload worker (default off), youtube-svc + group poller, Beijing time UX, and SHORTS.md.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-10 00:04:06 -05:00

3.3 KiB
Raw Blame History

Shorts 旁路说明

抖音监控开播/在播 → 短成片(ffmpeg)→ YouTube Shorts 上传。
独立可选路径:默认关闭;异常不影响抖音监控、封面、Webhook、场次。

线上:https://dylive.nomadro.com/shorts
OAuth 回调:https://dylive.nomadro.com/api/shorts/oauth/callback

隔离规则

规则 说明
默认关 shorts_enabled=false,worker 空转休眠
不阻塞监控 开播钩子 try/except;长耗时录制在独立 asyncio 任务
不占 sh2 不复用 RTMP 转播车道;仅 check_room 取流地址后 ffmpeg 拉一段
日去重 同一 room_id 北京日默认只入队一次(shorts_dedupe_room_day)

入队来源

  1. 开播边缘:监控检测到新开播且房间匹配触发规则时入队
  2. 在播随机取样(默认开):从 SQLite 中 last_status=live 的抖音房随机抽,默认不限标签(shorts_sample_any_live)

手动:POST /api/shorts/sample-now 或 Shorts 页「立即随机取样」。

成片时长

配置 值
shorts_clip_sec 默认 15;可选 30 / 60 / 90

设置页「Shorts → 成片时长」下拉切换,保存后对新任务生效。

Google OAuth(一键授权)

  1. Google Cloud 启用 YouTube Data API v3
  2. OAuth 同意屏幕(External)+ Test users
  3. 创建 Web application 客户端:
    • JavaScript origins:https://dylive.nomadro.com(不要带路径)
    • Redirect URI:https://dylive.nomadro.com/api/shorts/oauth/callback
  4. 在 Shorts 页「一键打开」引导中粘贴 Client ID / Secret 并保存
  5. 每个上传频道点 Google 授权(多品牌频道各授权一次)

未验证应用:授权页点 Advanced → Go to dylive (unsafe)。

频道配额

每个 Shorts 频道配置 daily_min / daily_max(如 5–9)。
调度优先未达下限、再选当日任务更少的频道。单频道时自然全部进该频道,且同房当天不重复。

关键设置键

键 默认 说明
shorts_enabled false 总开关
shorts_clip_sec 15 成片秒数
shorts_live_sample true 在播随机取样
shorts_live_sample_interval_sec 180 取样间隔
shorts_live_sample_batch 1 每次入队条数
shorts_sample_any_live true 取样不限标签
shorts_trigger tagged 开播钩子触发:tagged / favorite / all
shorts_tag shorts tagged 模式标签名
shorts_dedupe_room_day true 同房日去重
shorts_auto_upload true 录完自动上传
shorts_oauth_client_* 空 全局 OAuth Client

主要代码

文件 职责
backend/app/shorts_pipeline.py worker、取样、入队、录制/上传编排
backend/app/shorts_clip.py ffmpeg 成片
backend/app/shorts_upload.py YouTube resumable upload
backend/app/shorts_oauth.py OAuth start / callback
frontend/src/app/shorts/page.tsx 管理页
scripts/deploy_shorts.py VPS 增量部署

部署

python scripts\deploy_shorts.py

验证:

curl -sS http://127.0.0.1:8014/api/shorts/status
curl -sS http://127.0.0.1:8014/api/monitor/status

期望:shorts.enabled 按设置;monitor.running=true 不受影响。