mcpField
M
media-downloader

media-downloader

github.com/dp-archive创意与媒体1.1k47 次安装34 周前更新
代码仓库

关于 media-downloader

media-downloader 是一项围绕 yt-dlp 的媒体下载技能,面向需要保存在线视频和音频的用户。它涵盖格式、字幕、播放列表和文件命名等常见下载设置。

主要功能

  1. 01从 1500 多个网站下载媒体
  2. 02选择画质与输出格式
  3. 03下载手动或自动字幕
  4. 04处理播放列表与指定条目
  5. 05自定义文件命名模板

适用场景

  1. 01下载指定分辨率的视频
  2. 02保存视频并附带多语言字幕
  3. 03批量下载播放列表中的条目
  4. 04按上传者或日期整理文件

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/dp-archive/archive --skill media-downloader

安装后在 Claude Code 中输入/media-downloader确认已加载。

附带文件scripts/download.py

详细介绍

媒体下载器

使用 yt-dlp 从 1500 多个网站下载视频/音频。支持格式选择、字幕、播放列表和自定义输出命名。

快速开始

# Basic download (best quality)
yt-dlp "URL"

# Specific resolution
yt-dlp -f "bestvideo[height<=1080]+bestaudio/best[height<=1080]" "URL"

# With subtitles
yt-dlp --write-subs --sub-langs "en,zh" "URL"

# Audio only
yt-dlp -f "bestaudio" "URL"

格式选择

分辨率预设
请求命令
最佳画质-f "bestvideo+bestaudio/best"
4K-f "bestvideo[height<=2160]+bestaudio/best"
1080p-f "bestvideo[height<=1080]+bestaudio/best"
720p-f "bestvideo[height<=720]+bestaudio/best"
480p-f "bestvideo[height<=480]+bestaudio/best"
列出可用格式
yt-dlp -F "URL"  # Show all formats with codes
高级格式选择
# Prefer MP4 container
yt-dlp -f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best" "URL"

# Specific format code (from -F output)
yt-dlp -f 137+140 "URL"

# Merge to specific container
yt-dlp --merge-output-format mkv "URL"

字幕

下载字幕
# Manual subtitles (human-created)
yt-dlp --write-subs --sub-langs "en,zh,ja" "URL"

# Auto-generated subtitles
yt-dlp --write-auto-subs --sub-langs "en" "URL"

# Both manual and auto
yt-dlp --write-subs --write-auto-subs --sub-langs "en,zh" "URL"

# Embed subtitles in video (MP4/MKV/WebM)
yt-dlp --write-subs --embed-subs "URL"
列出可用字幕
yt-dlp --list-subs "URL"
字幕格式
# Convert to SRT
yt-dlp --write-subs --sub-format srt "URL"

# Available: srt, ass, vtt, lrc

输出命名

模板变量
变量描述示例
%(title)s视频标题My Video
%(id)s视频 IDdQw4w9WgXcQ
%(ext)s文件扩展名mp4
%(upload_date)s上传日期20231215
%(uploader)s频道名称Rick Astley
%(playlist)s播放列表名称Best Songs
%(playlist_index)s在播放列表中的位置01
%(resolution)s视频分辨率1920x1080
常见模式
# Default: title + extension
yt-dlp -o "%(title)s.%(ext)s" "URL"

# Date prefix
yt-dlp -o "%(upload_date)s - %(title)s.%(ext)s" "URL"

# Organized by uploader
yt-dlp -o "%(uploader)s/%(title)s.%(ext)s" "URL"

# Playlist with numbering
yt-dlp -o "%(playlist)s/%(playlist_index)02d - %(title)s.%(ext)s" "URL"

# Sanitize title (remove special chars)
yt-dlp -o "%(title).100B.%(ext)s" "URL"  # Limit to 100 bytes

播放列表处理

# Download entire playlist
yt-dlp "PLAYLIST_URL"

# Only video (not playlist)
yt-dlp --no-playlist "URL"

# Specific items (1-indexed)
yt-dlp -I 1:5 "PLAYLIST_URL"        # First 5
yt-dlp -I 1,3,5 "PLAYLIST_URL"      # Items 1, 3, 5
yt-dlp -I -3: "PLAYLIST_URL"        # Last 3

# Skip already downloaded
yt-dlp --download-archive downloaded.txt "PLAYLIST_URL"

平台特定说明

YouTube
  • 支持:视频、播放列表、频道、Shorts、直播
  • 下载受年龄限制或会员专属内容可能需要 Cookie
Bilibili
  • 下载高级内容时使用 --cookies-from-browser
  • 字幕:--write-subs --sub-langs "zh-Hans"
TikTok / Douyin
  • 可直接使用 URL 下载
  • 某些情况下可能带有水印
Twitter/X
  • 支持视频推文和 Spaces
  • 下载私密内容时使用 --cookies-from-browser
Instagram
  • 故事需要登录
  • 使用 --cookies-from-browser firefox 或 --cookies cookies.txt

身份验证

# Browser cookies (recommended)
yt-dlp --cookies-from-browser firefox "URL"
yt-dlp --cookies-from-browser chrome "URL"

# Cookie file
yt-dlp --cookies cookies.txt "URL"

# Username/password (limited support)
yt-dlp -u USERNAME -p PASSWORD "URL"

故障排除

常见问题
问题解决方案
“视频不可用”尝试 --cookies-from-browser
下载速度慢添加 --concurrent-fragments 4
格式合并失败安装 ffmpeg
地理限制使用 --geo-bypass 或代理
更新 yt-dlp
yt-dlp -U  # Update to latest stable

完整示例

下载带有中文字幕的 1080p YouTube 视频:

yt-dlp -f "bestvideo[height<=1080]+bestaudio/best" \
       --write-subs --sub-langs "zh" \
       -o "%(title)s.%(ext)s" \
       "https://youtube.com/watch?v=..."

下载 TikTok 视频:

yt-dlp -o "%(uploader)s - %(title)s.%(ext)s" \
       "https://tiktok.com/@user/video/..."

下载 Bilibili 播放列表:

yt-dlp --cookies-from-browser chrome \
       -o "%(playlist)s/%(playlist_index)02d - %(title)s.%(ext)s" \
       "https://bilibili.com/video/BV..."

下载 Twitter 视频:

yt-dlp --cookies-from-browser firefox \
       "https://twitter.com/user/status/..."

评论

支持 Markdown