YouTube Digest
Use a transcript-first workflow.
Quick workflow
- 1. Run
scripts/fetch_youtube.py <url> --out <dir> to collect metadata and subtitles.
If behind a proxy, add
--proxy <proxy-url>.
- 2. If subtitles exist, read
summary.json and the generated transcript file first. - If the user only wants a quick answer, summarize directly from the transcript.
- If the user needs stronger visual grounding, extract key frames with ffmpeg after downloading the video or by using an existing local video file.
- If no subtitles are available, report that transcript extraction needs
yt-dlp + a speech-to-text path (for example Whisper) before promising a result.
Default behavior
- - Prefer manual subtitles over auto subtitles.
- Prefer Chinese subtitles when available; otherwise use English auto/manual subtitles.
- Keep downloads minimal: subtitles + metadata first, full video only when visual analysis is necessary.
- For long videos, produce:
- 3-line executive summary
- bullet timeline with timestamps
- key insights / actionable points
- open questions or uncertainties
Outputs
For normal requests, return:
- - Video topic
- Summary (in user's language)
- Key timestamps
- Notable quotes / insights
- If confidence is limited, say whether the result came from manual subtitles, auto subtitles, or partial metadata only.
Files produced by the script
The fetch script writes an output directory containing:
- -
summary.json — chosen subtitle file, title, uploader, duration, and extraction status - INLINECODE5 — plain text transcript when subtitles are available
- raw subtitle files from
yt-dlp (VTT/SRT)
Read summary.json first to decide what to do next.
Required runtime tools
- -
yt-dlp for metadata + subtitle extraction - INLINECODE9 as JS runtime (required by yt-dlp 2026+)
- INLINECODE10 for media conversion / optional frame extraction (optional)
Key commands
Basic extraction:
CODEBLOCK0
With proxy:
CODEBLOCK1
Prefer specific subtitle languages:
CODEBLOCK2
Failure handling
- - If
yt-dlp is missing, stop and install it instead of improvising. - If YouTube blocks the request (429 or bot detection), try using a proxy or report the limitation.
- If only metadata is available, do not pretend you understood the full video.
- If subtitles are auto-generated, mention that wording may be noisy.
References
- - Read
references/install-and-deploy.md for deployment instructions. - Read
references/usage-patterns.md for output templates for summaries, translations, or Q&A.
YouTube Digest
使用优先处理转录文本的工作流程。
快速工作流程
- 1. 运行 scripts/fetch_youtube.py --out 收集元数据和字幕。
如果使用代理,添加 --proxy
参数。
- 2. 如果存在字幕,首先读取 summary.json 和生成的转录文件。
- 如果用户仅需快速回答,直接从转录文本中总结。
- 如果用户需要更强的视觉依据,在下载视频后使用 ffmpeg 提取关键帧,或使用已有的本地视频文件。
- 如果没有可用字幕,报告转录提取需要 yt-dlp 加上语音转文字工具(例如 Whisper),才能给出结果。
默认行为
- - 优先使用手动字幕而非自动字幕。
- 有中文字幕时优先使用;否则使用英文自动/手动字幕。
- 最小化下载:优先下载字幕和元数据,仅在需要视觉分析时才下载完整视频。
- 对于长视频,生成:
- 三行执行摘要
- 带时间戳的要点时间线
- 关键见解/可操作要点
- 未解决的问题或不确定性
输出内容
对于常规请求,返回:
- - 视频主题
- 摘要(使用用户语言)
- 关键时间戳
- 值得注意的引述/见解
- 如果置信度有限,说明结果来自手动字幕、自动字幕还是仅部分元数据。
脚本生成的文件
抓取脚本会创建一个输出目录,包含:
- - summary.json — 所选字幕文件、标题、上传者、时长和提取状态
- transcript.txt — 有字幕时的纯文本转录
- 来自 yt-dlp 的原始字幕文件(VTT/SRT)
首先读取 summary.json 以决定后续操作。
必需的运行时工具
- - yt-dlp 用于元数据和字幕提取
- deno 作为 JS 运行时(yt-dlp 2026+ 版本需要)
- ffmpeg 用于媒体转换/可选的帧提取(可选)
关键命令
基本提取:
bash
python3 scripts/fetch_youtube.py --out /tmp/youtube-digest
使用代理:
bash
python3 scripts/fetch_youtube.py --proxy http://your-proxy:port --out /tmp/youtube-digest
指定字幕语言:
bash
python3 scripts/fetch_youtube.py --langs zh.,en. --out /tmp/youtube-digest
失败处理
- - 如果缺少 yt-dlp,停止并安装它,不要临时凑合。
- 如果 YouTube 阻止请求(429 或机器人检测),尝试使用代理或报告限制。
- 如果仅有元数据,不要假装理解了完整视频。
- 如果字幕是自动生成的,说明措辞可能不准确。
参考文档
- - 阅读 references/install-and-deploy.md 了解部署说明。
- 阅读 references/usage-patterns.md 了解摘要、翻译或问答的输出模板。