agentleFS
wty-yywty-yy/skills/youtube-download/SKILL.md

youtube-download

Skill2 starsChanged 2 months agoMITView on GitHub

Download YouTube (and other yt-dlp sites) audio or video with quality selection, bilingual English + Simplified Chinese subtitles, and browser-cookie authentication. Use when the user asks to download a YouTube video, extract music/audio, save a playlist, or fetch subtitles.

  • Installs packages

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Ask the user for the audio/video quality every time before starting a download, unless they already stated it:

    line 19
  2. Very specific:

    When run directly in a terminal, youtube_download.py prompts for mode and quality itself.

    line 24

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

YouTube Download

Download audio or video from YouTube with quality selection, using the local browser login to pass bot checks.

When To Use

  • Download a YouTube video (single video or playlist).
  • Extract audio as m4a, opus, flac, mp3, or the native best stream.
  • Fetch subtitles, including bilingual English + Simplified Chinese.
  • Any yt-dlp-supported URL (Vimeo, Bilibili, etc.) with the same workflow.

Before Downloading: Always Ask Quality

Ask the user for the audio/video quality every time before starting a download, unless they already stated it:

  • Audio: m4a (default), opus, flac, mp3, best.
  • Video: max height 2160 / 1440 / 1080 (default) / 720 / 480.

When run directly in a terminal, youtube_download.py prompts for mode and quality itself. When driving it from an agent, ask the user with the agent's question tool, then pass the answer as -f (audio) or -r (video) so the script does not prompt again.

Quick Start

pip install -U yt-dlp mutagen      # yt-dlp + cover-art embedding
# ffmpeg and node must be on PATH

# Unified entry: asks audio/video, then quality
python3 scripts/youtube_download.py "URL"

# Audio only, saved to audios/
python3 scripts/yt_audio_downloader.py -f flac "URL"
python3 scripts/yt_audio_downloader.py -f m4a -i urls.md

# Video, saved to videos/, default mkv + bilingual subtitles
python3 scripts/yt_video_downloader.py -r 1080 "URL"
python3 scripts/yt_video_downloader.py -r 2160 --codec av1 "URL"

Output layout (relative to the working directory):

audios/   # audio downloads
videos/   # video downloads

Defaults

  • Video container: mkv (stream copy, no re-encode).
  • Video subtitles: --subs auto, languages en,zh-Hans.
  • Bilingual subtitle: English on top, Simplified Chinese below, both at font size 38; written as a .bilingual.srt sidecar and embedded as ASS in the mkv.
  • Audio: original stream, no re-encode.

Implementation Details

Authentication and JS challenges

YouTube returns Sign in to confirm you're not a bot for datacenter IPs and headless requests. The scripts pass:

  • --cookies-from-browser chrome to reuse the local login session.
  • --js-runtimes node:<path> plus --remote-components ejs:github to solve the signature/n challenges.

yd_common.find_node() also locates nvm installs not on PATH.

Bilingual subtitles

make_bilingual_subs.py merges two auto-caption SRT tracks:

  1. Parse SRT tolerating blank lines inside cue text.
  2. De-roll YouTube's rolling two-line window (each cue repeats the previous line).
  3. Align English and Chinese cues by start timestamp.
  4. Emit a bilingual .srt and a styled .ass (English + Chinese stacked via {\rEN}...\N{\rCN}...).

yd_common.postprocess_bilingual() runs after yt-dlp, then remuxes the ASS into the mkv with ffmpeg -c copy -c:s ass.

Audio format facts

YouTube audio is already lossy (AAC ~128k or Opus ~137k), so flac/wav only store the lossy source without extra loss, they do not improve quality; it is the largest option. To keep the source exactly, use best; for compatibility use m4a; for small size use opus.

Troubleshooting

SymptomFix
Sign in to confirm you're not a botEnsure --cookies-from-browser chrome points at a logged-in browser
Formats missing / signature errorsInstall Node.js; keep --remote-components ejs:github
Chinese shows as boxesInstall a CJK font such as Noto Sans CJK SC
NoneType thumbnail warningpip install mutagen for ASS/FLAC cover embedding
mp4 lacks font stylingUse mkv; mp4 converts ASS to mov_text and drops the font size
Large flac filesExpected: FLAC stores PCM losslessly; use m4a for smaller files

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.