yt-dlp Video Downloader (OpenClaw)
Use yt-dlp to download videos from thousands of sites.
When to use
- - User shares a video URL and asks to download
- User requests audio-only (MP3) extraction
- User needs subtitles or specific quality
Safety
- - Never execute arbitrary shell built from untrusted text; always validate URL scheme (http/https only)
- Prefer the default download path under the user Downloads directory unless a safe path is explicitly provided
Quick checks
- - Ensure
yt-dlp exists on PATH; if missing, use installer metadata to guide installation - For MP3 extraction,
ffmpeg is recommended; proceed with a warning if unavailable
Common commands
CODEBLOCK0
- - YouTube with cookies (avoid 403)
CODEBLOCK1
CODEBLOCK2
- - With subtitles (all languages)
CODEBLOCK3
- - Specific quality (720p / 1080p)
yt-dlp -P "~/Downloads/yt-dlp" -f "bestvideo[height<=720]+bestaudio/best[height<=720]" "VIDEO_URL"
CODEBLOCK5
- - List formats, then pick one
CODEBLOCK6
Workflow
- 1. Detect platform (YouTube often needs
--cookies-from-browser chrome) - Ask for intent if unclear (video vs audio, subs, quality, output directory)
- Build a safe command (http/https URL, sanitize output path)
- Execute using the system exec tool
- Report saved path and any errors; suggest
-F on format errors
Troubleshooting
- - 403 on YouTube → add INLINECODE4
- Missing ffmpeg for audio → warn and suggest installing ffmpeg
- Interrupted downloads → yt-dlp auto-resumes on retry
yt-dlp 视频下载器 (OpenClaw)
使用 yt-dlp 从数千个网站下载视频。
使用场景
- - 用户分享视频链接并要求下载
- 用户请求仅提取音频(MP3)
- 用户需要字幕或特定画质
安全事项
- - 切勿执行由不可信文本构建的任意 shell 命令;始终验证 URL 协议(仅限 http/https)
- 除非明确提供安全路径,否则优先使用用户下载目录下的默认下载路径
快速检查
- - 确保 yt-dlp 存在于 PATH 环境变量中;若缺失,使用安装程序元数据指导安装
- 对于 MP3 提取,推荐使用 ffmpeg;若不可用,则发出警告并继续执行
常用命令
bash
yt-dlp -P ~/Downloads/yt-dlp 视频链接
- - 使用 cookies 下载 YouTube(避免 403 错误)
bash
yt-dlp -P ~/Downloads/yt-dlp --cookies-from-browser chrome YouTube链接
bash
yt-dlp -P ~/Downloads/yt-dlp -x --audio-format mp3 视频链接
bash
yt-dlp -P ~/Downloads/yt-dlp --write-subs --sub-langs all 视频链接
bash
yt-dlp -P ~/Downloads/yt-dlp -f bestvideo[height<=720]+bestaudio/best[height<=720] 视频链接
bash
yt-dlp -P ~/Downloads/yt-dlp -f bestvideo[height<=1080]+bestaudio/best[height<=1080] 视频链接
bash
yt-dlp -F 视频链接
yt-dlp -P ~/Downloads/yt-dlp -f 格式ID 视频链接
工作流程
- 1. 检测平台(YouTube 通常需要 --cookies-from-browser chrome)
- 若意图不明确则询问用户(视频或音频、字幕、画质、输出目录)
- 构建安全命令(http/https URL,清理输出路径)
- 使用系统执行工具运行命令
- 报告保存路径及任何错误;遇到格式错误时建议使用 -F 参数
故障排除
- - YouTube 出现 403 错误 → 添加 --cookies-from-browser chrome
- 缺少 ffmpeg 导致无法提取音频 → 发出警告并建议安装 ffmpeg
- 下载中断 → yt-dlp 会在重试时自动续传