youtube-downloader

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

YouTube Video Downloader (yt-dlp)

YouTube视频下载工具(yt-dlp)

Download videos from YouTube and 1000+ other sites using yt-dlp.
使用yt-dlp从YouTube及1000+其他平台下载视频。

Description

功能说明

A powerful video downloader skill based on yt-dlp that supports YouTube, Bilibili, Twitter/X, TikTok, and many other platforms. Features include format selection, audio extraction, subtitle download, playlist support, and metadata preservation.
一款基于yt-dlp的强大视频下载工具,支持YouTube、Bilibili、Twitter/X、TikTok等众多平台。功能包括格式选择、音频提取、字幕下载、播放列表支持以及元数据保留。

When to Use

使用场景

Use this skill when users:
  • Provide YouTube URLs and want to download videos
  • Mention "download video", "下载视频", "save video from YouTube"
  • Want to extract audio from videos (MP3)
  • Need to download playlists or channels
  • Want subtitles/captions from videos
  • Request video download from supported sites (Bilibili, Twitter, TikTok, etc.)
当用户出现以下需求时可使用本工具:
  • 提供YouTube链接并希望下载视频时
  • 提及“download video”、“下载视频”、“save video from YouTube”时
  • 希望从视频中提取音频(MP3格式)时
  • 需要下载播放列表或频道内容时
  • 想要获取视频字幕/字幕文件时
  • 请求从支持的平台(Bilibili、Twitter、TikTok等)下载视频时

Features

核心功能

  • Multi-Platform Support: YouTube, Bilibili, Twitter/X, TikTok, Vimeo, and 1000+ sites
  • Format Selection: Choose video quality (1080p, 720p, 4K) or audio-only
  • Audio Extraction: Extract audio as MP3, M4A, or other formats
  • Subtitle Download: Auto-download subtitles in multiple languages
  • Playlist Support: Download entire playlists or channels
  • Metadata Preservation: Save video info, thumbnails, and descriptions
  • Resume Support: Continue interrupted downloads
  • Progress Display: Real-time download progress
  • 多平台支持:YouTube、Bilibili、Twitter/X、TikTok、Vimeo及1000+其他平台
  • 格式选择:可选择视频画质(1080p、720p、4K)或仅音频模式
  • 音频提取:可将音频提取为MP3、M4A等格式
  • 字幕下载:自动下载多语言字幕
  • 播放列表支持:下载整个播放列表或频道内容
  • 元数据保留:保存视频信息、缩略图及描述
  • 断点续传:恢复中断的下载任务
  • 进度显示:实时展示下载进度

Usage

使用方法

Basic Syntax

基本语法

bash
python scripts/download_video.py "VIDEO_URL" [OPTIONS]
bash
python scripts/download_video.py "VIDEO_URL" [OPTIONS]

Common Scenarios

常见使用场景

Download single video (best quality):
bash
python scripts/download_video.py "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
Download video in specific quality:
bash
python scripts/download_video.py "https://www.youtube.com/watch?v=VIDEO_ID" -f 1080
Extract audio only (MP3):
bash
python scripts/download_video.py "https://www.youtube.com/watch?v=VIDEO_ID" --audio-only
Download with subtitles:
bash
python scripts/download_video.py "https://www.youtube.com/watch?v=VIDEO_ID" --subtitles
Download playlist:
bash
python scripts/download_video.py "https://www.youtube.com/playlist?list=PLAYLIST_ID" --playlist
Download N videos from playlist:
bash
python scripts/download_video.py "https://www.youtube.com/playlist?list=PLAYLIST_ID" --playlist -n 5
Specify output directory:
bash
python scripts/download_video.py "URL" -o /path/to/output
下载单个视频(最佳画质):
bash
python scripts/download_video.py "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
下载指定画质的视频:
bash
python scripts/download_video.py "https://www.youtube.com/watch?v=VIDEO_ID" -f 1080
仅提取音频(MP3格式):
bash
python scripts/download_video.py "https://www.youtube.com/watch?v=VIDEO_ID" --audio-only
下载视频及字幕:
bash
python scripts/download_video.py "https://www.youtube.com/watch?v=VIDEO_ID" --subtitles
下载播放列表:
bash
python scripts/download_video.py "https://www.youtube.com/playlist?list=PLAYLIST_ID" --playlist
下载播放列表中的前N个视频:
bash
python scripts/download_video.py "https://www.youtube.com/playlist?list=PLAYLIST_ID" --playlist -n 5
指定输出目录:
bash
python scripts/download_video.py "URL" -o /path/to/output

Arguments

参数说明

ArgumentDescriptionDefault
url
Video/Playlist URL (required)-
-o, --output
Output directoryCurrent directory
-f, --format
Video quality:
best
,
1080
,
720
,
480
,
360
best
--audio-only
Extract audio only (MP3)False
--subtitles
Download subtitlesFalse
--sub-lang
Subtitle language(s)
en,zh-Hans
--playlist
Enable playlist downloadFalse
-n, --count
Number of videos from playlistAll
--metadata
Save video metadata JSONTrue
--thumbnail
Download thumbnailFalse
--cookies
Path to cookies file (for age-restricted content)None
参数说明默认值
url
视频/播放列表链接(必填)-
-o, --output
输出目录当前目录
-f, --format
视频画质选项:
best
1080
720
480
360
best
--audio-only
启用仅音频提取模式(MP3格式)False
--subtitles
开启字幕下载False
--sub-lang
字幕语言选项
en,zh-Hans
--playlist
启用播放列表下载模式False
-n, --count
从播放列表中下载的视频数量全部
--metadata
保存视频元数据至JSON文件True
--thumbnail
下载视频缩略图False
--cookies
Cookie文件路径(用于访问年龄限制内容)None

Dependencies

依赖安装

bash
undefined
bash
undefined

Install yt-dlp

安装yt-dlp

pip install yt-dlp --break-system-packages
pip install yt-dlp --break-system-packages

For audio extraction (optional)

用于音频提取(可选)

macOS

macOS系统

brew install ffmpeg
brew install ffmpeg

Ubuntu/Debian

Ubuntu/Debian系统

apt-get install ffmpeg
undefined
apt-get install ffmpeg
undefined

Output Structure

输出结构

Single Video

单个视频输出

OutputDir/
├── Video Title [VIDEO_ID].mp4     # Video file
├── Video Title [VIDEO_ID].json    # Metadata (if --metadata)
├── Video Title [VIDEO_ID].jpg     # Thumbnail (if --thumbnail)
└── Video Title [VIDEO_ID].en.vtt  # Subtitles (if --subtitles)
OutputDir/
├── Video Title [VIDEO_ID].mp4     # 视频文件
├── Video Title [VIDEO_ID].json    # 元数据文件(若启用--metadata)
├── Video Title [VIDEO_ID].jpg     # 缩略图文件(若启用--thumbnail)
└── Video Title [VIDEO_ID].en.vtt  # 字幕文件(若启用--subtitles)

Playlist

播放列表输出

OutputDir/
└── PlaylistName/
    ├── playlist_info.json
    ├── 001 - Video Title.mp4
    ├── 001 - Video Title.json
    ├── 002 - Another Video.mp4
    └── ...
OutputDir/
└── PlaylistName/
    ├── playlist_info.json
    ├── 001 - Video Title.mp4
    ├── 001 - Video Title.json
    ├── 002 - Another Video.mp4
    └── ...

Metadata Example

元数据示例

json
{
  "title": "Video Title",
  "uploader": "Channel Name",
  "upload_date": "2024-01-15",
  "duration": 300,
  "view_count": 1000000,
  "description": "Video description...",
  "tags": ["tag1", "tag2"],
  "video_file": "Video Title [VIDEO_ID].mp4"
}
json
{
  "title": "Video Title",
  "uploader": "Channel Name",
  "upload_date": "2024-01-15",
  "duration": 300,
  "view_count": 1000000,
  "description": "Video description...",
  "tags": ["tag1", "tag2"],
  "video_file": "Video Title [VIDEO_ID].mp4"
}

Claude Integration

与Claude集成

When user requests video download:
  1. Read skill documentation:
    python
    view("/mnt/skills/user/youtube-downloader/SKILL.md")
  2. Install dependencies (if needed):
    bash
    pip install yt-dlp --break-system-packages
  3. Execute download:
    bash
    python /mnt/skills/user/youtube-downloader/scripts/download_video.py \
      "USER_URL" -o /mnt/user-data/outputs
  4. Present files to user:
    python
    present_files(["/mnt/user-data/outputs/..."])
当用户请求视频下载时:
  1. 查看技能文档:
    python
    view("/mnt/skills/user/youtube-downloader/SKILL.md")
  2. 安装依赖(如未安装):
    bash
    pip install yt-dlp --break-system-packages
  3. 执行下载:
    bash
    python /mnt/skills/user/youtube-downloader/scripts/download_video.py \
      "USER_URL" -o /mnt/user-data/outputs
  4. 向用户交付文件:
    python
    present_files(["/mnt/user-data/outputs/..."])

Supported Platforms

支持的平台

Major Platforms

主流平台

  • YouTube: Videos, Shorts, Playlists, Channels, Live streams
  • Bilibili: Videos, Episodes (may need cookies)
  • Twitter/X: Video tweets
  • TikTok: Videos (may need cookies)
  • Vimeo: Videos
  • Twitch: VODs, Clips
  • YouTube: 普通视频、Shorts短视频、播放列表、频道、直播回放
  • Bilibili: 普通视频、剧集(可能需要Cookie)
  • Twitter/X: 视频推文
  • TikTok: 短视频(可能需要Cookie)
  • Vimeo: 视频内容
  • Twitch: 点播视频(VODs)、精彩片段(Clips)

Full List

完整平台列表

yt-dlp supports 1000+ sites. Run
yt-dlp --list-extractors
for full list.
yt-dlp支持1000+平台,运行
yt-dlp --list-extractors
可查看完整列表。

Common Issues

常见问题

Q: Age-restricted videos? A: Use
--cookies
with exported browser cookies:
--cookies cookies.txt
Q: Format not available? A: Some videos may not have all quality options. Script will auto-select best available.
Q: Download speed slow? A: This is usually server-side throttling. Consider using a VPN or waiting.
Q: Need to login for private videos? A: Export cookies from your browser after logging in, then use
--cookies
.
Q: Audio extraction fails? A: Install ffmpeg:
brew install ffmpeg
(macOS) or
apt install ffmpeg
(Linux)
Q: 无法下载年龄限制的视频? A: 使用
--cookies
参数配合导出的浏览器Cookie文件:
--cookies cookies.txt
Q: 目标格式不可用? A: 部分视频可能不支持所有画质选项,工具会自动选择可用的最佳画质。
Q: 下载速度缓慢? A: 这通常是源服务器限流导致,可尝试使用VPN或稍后再试。
Q: 下载私人视频需要登录? A: 登录浏览器后导出Cookie文件,然后使用
--cookies
参数。
Q: 音频提取失败? A: 安装ffmpeg工具:macOS系统使用
brew install ffmpeg
,Linux系统使用
apt install ffmpeg

Example Conversations

对话示例

User: "帮我下载这个 YouTube 视频: https://www.youtube.com/watch?v=dQw4w9WgXcQ"
Claude:
bash
undefined
用户: "帮我下载这个 YouTube 视频: https://www.youtube.com/watch?v=dQw4w9WgXcQ"
Claude:
bash
undefined

Install yt-dlp

安装yt-dlp

pip install yt-dlp --break-system-packages
pip install yt-dlp --break-system-packages

Download video

下载视频

python /mnt/skills/user/youtube-downloader/scripts/download_video.py
"https://www.youtube.com/watch?v=dQw4w9WgXcQ"
-o /mnt/user-data/outputs
python /mnt/skills/user/youtube-downloader/scripts/download_video.py
"https://www.youtube.com/watch?v=dQw4w9WgXcQ"
-o /mnt/user-data/outputs

Present files

交付文件

present_files([...])

---

**User**: "下载这个 YouTube 视频的音频,我只要 MP3"

**Claude**:
```bash
python /mnt/skills/user/youtube-downloader/scripts/download_video.py \
  "VIDEO_URL" \
  --audio-only \
  -o /mnt/user-data/outputs

User: "Download this playlist, but only the first 5 videos"
Claude:
bash
python /mnt/skills/user/youtube-downloader/scripts/download_video.py \
  "PLAYLIST_URL" \
  --playlist -n 5 \
  -o /mnt/user-data/outputs
present_files([...])

---

**用户**: "下载这个 YouTube 视频的音频,我只要 MP3"

**Claude**:
```bash
python /mnt/skills/user/youtube-downloader/scripts/download_video.py \
  "VIDEO_URL" \
  --audio-only \
  -o /mnt/user-data/outputs

User: "Download this playlist, but only the first 5 videos"
Claude:
bash
python /mnt/skills/user/youtube-downloader/scripts/download_video.py \
  "PLAYLIST_URL" \
  --playlist -n 5 \
  -o /mnt/user-data/outputs

How It Works

工作原理

Workflow

工作流程

  1. URL Parsing: Detect platform and content type (video/playlist)
  2. Format Selection: Determine best available format based on user preference
  3. Download: Stream video/audio with progress display
  4. Post-Processing: Extract audio (if requested), embed subtitles
  5. Metadata: Save video information to JSON
  1. URL解析: 检测平台及内容类型(视频/播放列表)
  2. 格式选择: 根据用户偏好确定最佳可用格式
  3. 下载任务: 流式下载视频/音频并展示进度
  4. 后处理: 提取音频(若请求)、嵌入字幕
  5. 元数据保存: 将视频信息保存至JSON文件

Under the Hood

底层实现

This skill wraps yt-dlp with sensible defaults:
  • Automatic format selection for best quality
  • Proper filename sanitization
  • Retry logic for failed downloads
  • Progress display with ETA
本工具基于yt-dlp封装,提供合理的默认配置:
  • 自动选择最佳画质格式
  • 文件名自动清理
  • 失败下载的重试逻辑
  • 带预计完成时间的进度显示

Limitations

局限性

  • Some sites may require authentication (cookies)
  • Age-restricted content needs browser cookies
  • Download speed depends on source server
  • Some DRM-protected content cannot be downloaded
  • Live streams can only be downloaded after they end (VOD)
  • 部分平台可能需要身份验证(Cookie)
  • 年龄限制内容需要浏览器Cookie
  • 下载速度取决于源服务器
  • 受DRM保护的内容无法下载
  • 直播内容仅能在结束后下载(转为点播视频)

Legal Notice

法律声明

This tool is for personal use only. Please respect:
  • YouTube Terms of Service
  • Copyright laws in your jurisdiction
  • Content creators' rights
Only download content you have the right to access. Do not redistribute copyrighted material.
本工具仅用于个人使用。请遵守:
  • YouTube服务条款
  • 所在地区的版权法
  • 内容创作者的权利
仅下载您有权访问的内容,请勿分发受版权保护的材料。

Version History

版本历史

v1.0 (Current)
  • Initial release with yt-dlp wrapper
  • Support for video, audio, subtitles, playlists
  • Metadata and thumbnail preservation
  • Multi-platform support
v1.0(当前版本)
  • 初始版本,基于yt-dlp封装
  • 支持视频、音频、字幕、播放列表下载
  • 保留元数据和缩略图
  • 多平台支持

References

参考链接