tube-summary
Search YouTube for videos on any topic, then extract and summarize their content using subtitles.
Quick Start
Step 1: Search for Videos
When asked about a topic, search YouTube and list the top 10 results:
CODEBLOCK0
This returns a numbered list of videos with titles, channels, and view counts.
Step 2: User Picks a Video
The user selects one video by number (e.g., "3" for the third video).
Step 3: Download Subtitles
Extract English subtitles from the selected video using yt-dlp:
CODEBLOCK1
This creates a .en.vtt subtitle file without downloading the video.
Step 4: Process & Summarize
Use the subtitle processor to analyze and summarize:
CODEBLOCK2
This generates:
- - Key Topics: Main subjects covered in the video
- Summary: Concise 2-3 paragraph description of content
- Timestamps: Notable moments with context
- Key Quotes: Important statements from speakers
Workflow
- 1. Search →
youtube-search.py "<topic>" → Display top 10 videos - User selects → e.g., "Video 5"
- Extract URL → From the search results
- Download subs → INLINECODE2
- Process → INLINECODE3
- Present → Formatted summary with key points
Prerequisites
- -
yt-dlp (install: pip install yt-dlp) - INLINECODE6 (for YouTube search fallback)
- Python 3.7+
Notes
- - If YouTube search API is unavailable, the fallback uses web scraping via requests
- Subtitles may be auto-generated if not manually authored
- Some videos may not have English subtitles available
- The subtitle file is created in the same directory as yt-dlp is run
Example Usage
CODEBLOCK3
tube-summary
在YouTube上搜索任何主题的视频,然后使用字幕提取并总结其内容。
快速开始
第一步:搜索视频
当被问及某个主题时,搜索YouTube并列出前10个结果:
bash
python3 scripts/youtube-search.py 你的搜索关键词
这将返回一个带编号的视频列表,包含标题、频道和观看次数。
第二步:用户选择视频
用户通过编号选择一个视频(例如,选择3表示第三个视频)。
第三步:下载字幕
使用yt-dlp从所选视频中提取英文字幕:
bash
yt-dlp --write-subs --sub-langs en --skip-download 视频URL
这将在不下载视频的情况下创建一个.en.vtt字幕文件。
第四步:处理与总结
使用字幕处理器进行分析和总结:
bash
python3 scripts/process-subtitles.py 字幕文件路径.vtt
这将生成:
- - 关键主题:视频涵盖的主要议题
- 总结:2-3段简洁的内容描述
- 时间戳:带有上下文的重点时刻
- 关键引述:演讲者的重要陈述
工作流程
- 1. 搜索 → youtube-search.py <主题> → 显示前10个视频
- 用户选择 → 例如视频5
- 提取URL → 从搜索结果中获取
- 下载字幕 → yt-dlp --write-subs --sub-langs en --skip-download URL
- 处理 → process-subtitles.py subtitle.vtt
- 呈现 → 带有要点的格式化总结
前提条件
- - yt-dlp(安装:pip install yt-dlp)
- requests(用于YouTube搜索备用方案)
- Python 3.7+
注意事项
- - 如果YouTube搜索API不可用,备用方案将通过requests进行网页抓取
- 如果没有手动创建字幕,可能会使用自动生成的字幕
- 某些视频可能没有英文字幕可用
- 字幕文件将创建在运行yt-dlp的同一目录中
使用示例
用户:给我讲讲Rust编程语言
→ 搜索返回10个关于Rust的视频
用户:总结视频3
→ 从视频3下载字幕
→ 处理并返回详细总结