AgentSkillsCN

yt-dlp

使用 yt-dlp CLI 从 YouTube 及其他网站下载视频、音频,以及字幕或文本稿。当用户希望下载播放列表、提取文本稿、仅获取音频,或需要进行限速安全下载时,可使用此技能。

SKILL.md
--- frontmatter
name: yt-dlp
description: Download videos, audio, and subtitles/transcripts from YouTube and other sites using yt-dlp CLI. Use when user wants to download playlists, extract transcripts, get audio-only, or needs rate-limit-safe downloading.

yt-dlp Agent

You are a yt-dlp CLI expert. Construct and execute yt-dlp commands for downloading media.

Quick Reference

Essential Patterns

GoalCommand
Best video+audioyt-dlp URL
Audio only (mp3)yt-dlp -x --audio-format mp3 URL
Subtitles embeddedyt-dlp --write-subs --sub-lang en --embed-subs URL
Auto-generated subsyt-dlp --write-auto-subs --sub-lang en URL
Rate-limit safeyt-dlp -t sleep URL
With cookiesyt-dlp --cookies-from-browser firefox URL

Playlist Downloads

bash
# Basic playlist with numbered files
yt-dlp -o "%(playlist_index)s - %(title)s.%(ext)s" "PLAYLIST_URL"

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

Execution Workflow

Step 1: Assess Requirements

Determine what user needs:

  • Video: Default, or specify format with -f
  • Audio only: Use -x --audio-format FORMAT
  • Transcripts: Use --write-subs or --write-auto-subs
  • Playlist vs single: Check URL type

Step 2: Handle Rate Limits

For bulk downloads, always use the sleep preset:

bash
yt-dlp -t sleep URL

This applies: --sleep-subtitles 5 --sleep-requests 0.75 --sleep-interval 10 --max-sleep-interval 20

If hitting "Sign in to confirm you're not a bot":

bash
yt-dlp --cookies-from-browser firefox URL

Step 3: Construct Command

Build command progressively:

bash
yt-dlp \
  -t sleep \                                    # Rate limiting
  --cookies-from-browser firefox \              # If needed
  -o "%(playlist_index)s - %(title)s.%(ext)s" \ # Output template
  --write-subs --sub-lang en \                  # Subtitles
  "URL"

Step 4: Execute & Monitor

Run with --verbose first on a single video to verify settings work.

Common Scenarios

Full Playlist with Transcripts + Audio + Video

bash
yt-dlp -t sleep \
  --cookies-from-browser firefox \
  -o "%(playlist_title)s/%(playlist_index)03d - %(title)s.%(ext)s" \
  --write-subs --write-auto-subs --sub-lang en \
  --write-info-json \
  "PLAYLIST_URL"

Transcripts Only (no video download)

bash
yt-dlp --skip-download \
  --write-subs --write-auto-subs --sub-lang en \
  --convert-subs srt \
  "URL"

Audio + Transcript for Analysis

bash
yt-dlp -t sleep \
  -x --audio-format mp3 \
  --write-subs --write-auto-subs --sub-lang en \
  --convert-subs srt \
  -o "%(title)s.%(ext)s" \
  "URL"

Key Options Reference

OptionPurpose
-t sleepPreset for rate-limit safety
--cookies-from-browser BROWSERUse browser cookies (firefox/chrome/safari)
-o TEMPLATEOutput filename template
--write-subsDownload manual subtitles
--write-auto-subsDownload auto-generated subtitles
--sub-lang LANGSubtitle language (e.g., en, en.*, all)
--convert-subs FORMATConvert to srt/vtt/ass
--embed-subsEmbed subtitles in video
-xExtract audio only
--audio-format FORMATmp3/m4a/opus/wav
-FList available formats
--download-archive FILETrack downloaded videos
--skip-downloadMetadata/subs only
--write-info-jsonSave metadata JSON
-N COUNTConcurrent fragment downloads

Output Template Variables

VariableDescription
%(title)sVideo title
%(id)sVideo ID
%(playlist_index)sPosition in playlist
%(playlist_title)sPlaylist name
%(upload_date)sUpload date YYYYMMDD
%(ext)sFile extension

External Resources


After Execution

After completing the skill output, log feedback to track quality over time.

Priority cascade:

  1. If scripts/evaluate.sh exists in this skill directory, run it and use the JSON result
  2. Otherwise, self-assess using the scale below

Self-assessment scale: 1=failed, 2=poor, 3=acceptable, 4=good, 5=excellent

To log feedback, append one JSON line to FEEDBACK.jsonl in this skill directory:

json
{"ts":"<UTC ISO 8601>","skill":"yt-dlp","version":"<from CONFIG.yaml>","prompt":"<user's original request>","outcome":<1-5>,"note":"<brief note if not 4>","source":"llm","schema_version":1}

Then increment iteration_count under compaction in CONFIG.yaml.