youtube-tools
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseYouTube Tools (yt-dlp)
YouTube Tools (yt-dlp)
Overview
概述
Free, local YouTube operations using yt-dlp. No API keys required, no per-video costs. Works offline after installation.
使用yt-dlp在本地免费操作YouTube内容。无需API密钥,无单视频成本。安装后可离线使用。
When to Use This vs Apify
何时选择本工具 vs Apify
┌─────────────────────────────────────────────────────────────────┐
│ DECISION: YouTube Tools (yt-dlp) vs Apify │
├─────────────────────────────────────────────────────────────────┤
│ │
│ Use youtube-tools (FREE) when: │
│ ├── Downloading videos to local storage │
│ ├── Extracting transcripts/subtitles │
│ ├── Getting video metadata (title, duration, views, etc.) │
│ ├── Bulk downloading playlists or channels │
│ ├── Converting to audio-only (MP3) │
│ └── You want zero API costs │
│ │
│ Use apify-scrapers when: │
│ ├── Scraping YouTube SEARCH results │
│ ├── Getting comments at scale │
│ ├── Channel analytics and statistics │
│ ├── Trending video discovery │
│ └── You need cloud-based processing │
│ │
└─────────────────────────────────────────────────────────────────┘┌─────────────────────────────────────────────────────────────────┐
│ 决策:YouTube Tools (yt-dlp) vs Apify │
├─────────────────────────────────────────────────────────────────┤
│ │
│ 在以下场景使用youtube-tools(免费): │
│ ├── 将视频下载到本地存储 │
│ ├── 提取字幕/文稿 │
│ ├── 获取视频元数据(标题、时长、播放量等) │
│ ├── 批量下载播放列表或频道内容 │
│ ├── 转换为仅音频格式(MP3) │
│ └── 希望零API成本 │
│ │
│ 在以下场景使用apify-scrapers: │
│ ├── 爬取YouTube搜索结果 │
│ ├── 大规模获取评论内容 │
│ ├── 频道分析与统计数据 │
│ ├── 发现热门视频 │
│ └── 需要基于云端的处理能力 │
│ │
└─────────────────────────────────────────────────────────────────┘Quick Decision Tree
快速决策树
What do you need?
│
├── Download video(s)
│ ├── Single video → scripts/download_video.py URL
│ ├── Multiple videos → scripts/download_video.py --urls-file list.txt
│ ├── Playlist → scripts/download_video.py "playlist_url"
│ ├── Audio only → scripts/download_video.py URL --audio-only
│ └── Specific quality → scripts/download_video.py URL --quality 720p
│
├── Get transcript/subtitles
│ ├── Auto-generated captions → scripts/get_transcript.py URL
│ ├── Manual subtitles → scripts/get_transcript.py URL --manual-only
│ ├── Specific language → scripts/get_transcript.py URL --lang es
│ └── All available → scripts/get_transcript.py URL --all-langs
│
├── Get video metadata
│ ├── Single video → scripts/get_video_info.py URL
│ ├── Multiple videos → scripts/get_video_info.py --urls-file list.txt
│ └── Playlist info → scripts/get_video_info.py "playlist_url"
│
└── Advanced
├── Age-restricted → scripts/download_video.py URL --cookies-from-browser chrome
├── Private videos → Requires authentication (see references/yt-dlp-guide.md)
└── Live streams → scripts/download_video.py URL --live-from-start你需要什么功能?
│
├── 下载视频
│ ├── 单个视频 → scripts/download_video.py URL
│ ├── 多个视频 → scripts/download_video.py --urls-file list.txt
│ ├── 播放列表 → scripts/download_video.py "playlist_url"
│ ├── 仅音频 → scripts/download_video.py URL --audio-only
│ └── 指定画质 → scripts/download_video.py URL --quality 720p
│
├── 获取字幕/文稿
│ ├── 自动生成字幕 → scripts/get_transcript.py URL
│ ├── 手动添加字幕 → scripts/get_transcript.py URL --manual-only
│ ├── 指定语言 → scripts/get_transcript.py URL --lang es
│ └── 所有可用字幕 → scripts/get_transcript.py URL --all-langs
│
├── 获取视频元数据
│ ├── 单个视频 → scripts/get_video_info.py URL
│ ├── 多个视频 → scripts/get_video_info.py --urls-file list.txt
│ └── 播放列表信息 → scripts/get_video_info.py "playlist_url"
│
└── 高级功能
├── 年龄限制视频 → scripts/download_video.py URL --cookies-from-browser chrome
├── 私有视频 → 需要身份验证(参考references/yt-dlp-guide.md)
└── 直播流 → scripts/download_video.py URL --live-from-startEnvironment Setup
环境搭建
bash
undefinedbash
undefinedInstall yt-dlp (required)
安装yt-dlp(必需)
pip install yt-dlp
pip install yt-dlp
Optional: Install ffmpeg for format conversion
可选:安装ffmpeg用于格式转换
macOS
macOS
brew install ffmpeg
brew install ffmpeg
Ubuntu/Debian
Ubuntu/Debian
sudo apt install ffmpeg
sudo apt install ffmpeg
Windows
Windows
winget install ffmpeg
**No API keys required!** This is completely free.winget install ffmpeg
**无需API密钥!** 完全免费。Common Usage
常见用法
Download Single Video
下载单个视频
bash
python scripts/download_video.py "https://www.youtube.com/watch?v=VIDEO_ID"bash
python scripts/download_video.py "https://www.youtube.com/watch?v=VIDEO_ID"Download with Specific Quality
下载指定画质的视频
bash
python scripts/download_video.py "https://youtu.be/VIDEO_ID" --quality 1080pbash
python scripts/download_video.py "https://youtu.be/VIDEO_ID" --quality 1080pDownload Audio Only (MP3)
仅下载音频(MP3格式)
bash
python scripts/download_video.py "https://youtube.com/watch?v=VIDEO_ID" --audio-onlybash
python scripts/download_video.py "https://youtube.com/watch?v=VIDEO_ID" --audio-onlyDownload Entire Playlist
下载整个播放列表
bash
python scripts/download_video.py "https://youtube.com/playlist?list=PLAYLIST_ID" --output-dir ./videosbash
python scripts/download_video.py "https://youtube.com/playlist?list=PLAYLIST_ID" --output-dir ./videosBulk Download from File
从文件批量下载
bash
undefinedbash
undefinedCreate urls.txt with one URL per line
创建urls.txt,每行一个URL
python scripts/download_video.py --urls-file urls.txt --output-dir ./downloads
undefinedpython scripts/download_video.py --urls-file urls.txt --output-dir ./downloads
undefinedGet Transcript
获取字幕文稿
bash
python scripts/get_transcript.py "https://youtube.com/watch?v=VIDEO_ID"bash
python scripts/get_transcript.py "https://youtube.com/watch?v=VIDEO_ID"Get Transcript in Specific Language
获取指定语言的字幕文稿
bash
python scripts/get_transcript.py "https://youtu.be/VIDEO_ID" --lang esbash
python scripts/get_transcript.py "https://youtu.be/VIDEO_ID" --lang esGet Video Metadata
获取视频元数据
bash
python scripts/get_video_info.py "https://youtube.com/watch?v=VIDEO_ID"bash
python scripts/get_video_info.py "https://youtube.com/watch?v=VIDEO_ID"Get Metadata for Multiple Videos
获取多个视频的元数据
bash
python scripts/get_video_info.py --urls-file videos.txt --output metadata.jsonbash
python scripts/get_video_info.py --urls-file videos.txt --output metadata.jsonOutput Location
输出位置
All outputs save to by default:
.tmp/youtube/- Videos:
.tmp/youtube/videos/ - Audio:
.tmp/youtube/audio/ - Transcripts:
.tmp/youtube/transcripts/ - Metadata:
.tmp/youtube/metadata/
所有输出默认保存到 :
.tmp/youtube/- 视频:
.tmp/youtube/videos/ - 音频:
.tmp/youtube/audio/ - 字幕文稿:
.tmp/youtube/transcripts/ - 元数据:
.tmp/youtube/metadata/
Cost
成本
FREE - No API keys, no per-video costs, no subscriptions.
完全免费 - 无需API密钥,无单视频成本,无订阅费用。
Security Notes
安全说明
Safe by Design
设计安全
- URL validation: Only accepts YouTube URLs (youtube.com, youtu.be)
- Filename sanitization: Removes dangerous characters
- Output restriction: Only writes to directory
.tmp/ - No shell injection: Uses subprocess with argument lists, not string concatenation
- No stored credentials: Cookies only used when explicitly requested
- URL验证:仅接受YouTube域名的链接(youtube.com, youtu.be)
- 文件名清理:移除危险字符
- 输出限制:仅写入 目录
.tmp/ - 无Shell注入风险:使用带参数列表的subprocess,而非字符串拼接
- 无凭证存储:仅在明确请求时使用Cookies
Copyright Warning
版权警告
- Only download content you have rights to access
- Respect YouTube's Terms of Service
- Do not redistribute copyrighted content
- Use for personal/educational purposes
- 仅下载你有权访问的内容
- 遵守YouTube服务条款
- 不要重新分发受版权保护的内容
- 仅限个人/教育用途
Rate Limiting
请求频率限制
- yt-dlp has built-in rate limiting
- For bulk downloads, use to avoid throttling
--sleep-interval 5 - YouTube may temporarily block IPs with excessive requests
- yt-dlp内置频率限制
- 批量下载时,使用 避免被限流
--sleep-interval 5 - 过度请求可能导致YouTube临时封禁IP
Troubleshooting
故障排除
Issue: "Video unavailable"
问题:"视频不可用"
Cause: Video is private, age-restricted, or region-locked
Solution: Use for age-restricted content
--cookies-from-browser chrome原因: 视频为私有、年龄限制或区域锁定
解决方案: 对年龄限制内容使用 参数
--cookies-from-browser chromeIssue: "Unable to extract video data"
问题:"无法提取视频数据"
Cause: YouTube changed their page structure
Solution: Update yt-dlp:
pip install -U yt-dlp原因: YouTube页面结构变更
解决方案: 更新yt-dlp:
pip install -U yt-dlpIssue: No subtitles found
问题:未找到字幕
Cause: Video has no captions (auto or manual)
Solution: Use to see available subtitles first
--list-subs原因: 视频无自动或手动添加的字幕
解决方案: 先使用 参数查看可用字幕
--list-subsIssue: Slow downloads
问题:下载速度慢
Cause: YouTube throttling or network issues
Solution: Try for faster downloads
--concurrent-fragments 4原因: YouTube限流或网络问题
解决方案: 尝试使用 参数提升下载速度
--concurrent-fragments 4Issue: Format conversion failed
问题:格式转换失败
Cause: ffmpeg not installed
Solution: Install ffmpeg (see Environment Setup)
原因: 未安装ffmpeg
解决方案: 安装ffmpeg(参考环境搭建部分)
Integration Patterns
集成模式
Download + Transcribe + Summarize
下载 + 提取字幕 + 总结
bash
undefinedbash
undefined1. Download video
1. 下载视频
python scripts/download_video.py "URL" --output-dir .tmp/video
python scripts/download_video.py "URL" --output-dir .tmp/video
2. Get transcript
2. 获取字幕文稿
python scripts/get_transcript.py "URL" --output .tmp/transcript.txt
python scripts/get_transcript.py "URL" --output .tmp/transcript.txt
3. Use content-generation to summarize
3. 使用内容生成工具进行总结
(transcript file is now ready for summarization)
(字幕文稿文件已准备好用于总结)
undefinedundefinedBulk Research Workflow
批量研究工作流
bash
undefinedbash
undefined1. Get metadata for research videos
1. 获取研究视频的元数据
python scripts/get_video_info.py --urls-file research_videos.txt --output .tmp/metadata.json
python scripts/get_video_info.py --urls-file research_videos.txt --output .tmp/metadata.json
2. Download transcripts for text analysis
2. 下载字幕文稿用于文本分析
python scripts/get_transcript.py --urls-file research_videos.txt --output-dir .tmp/transcripts
python scripts/get_transcript.py --urls-file research_videos.txt --output-dir .tmp/transcripts
3. Use parallel-research to analyze content
3. 使用并行研究工具分析内容
undefinedundefinedCourse Content Download
课程内容下载
bash
undefinedbash
undefinedDownload entire playlist as course modules
下载整个播放列表作为课程模块
python scripts/download_video.py "PLAYLIST_URL" --output-dir .tmp/course --quality 720p
python scripts/download_video.py "PLAYLIST_URL" --output-dir .tmp/course --quality 720p
Get all transcripts for notes
获取所有字幕文稿用于笔记
python scripts/get_transcript.py "PLAYLIST_URL" --output-dir .tmp/course/transcripts
undefinedpython scripts/get_transcript.py "PLAYLIST_URL" --output-dir .tmp/course/transcripts
undefinedResources
资源
- references/yt-dlp-guide.md - Complete yt-dlp reference with all options
- yt-dlp documentation: https://github.com/yt-dlp/yt-dlp#readme
- references/yt-dlp-guide.md - 包含所有选项的完整yt-dlp参考文档
- yt-dlp官方文档: https://github.com/yt-dlp/yt-dlp#readme