CLI utility for downloading a single YouTube video with explicit quality policy and machine-readable output.
- Downloads one video from
youtube.comoryoutu.beURL. - Supports strict exact-quality mode and best-effort fallback mode.
- Supports yt-dlp player client overrides and browser cookie import attempts.
- Provides stable machine-readable output with
--output json. - Supports
doctor,describe, andfetch --dry-runfor automation workflows.
- Python 3.10+
ffmpeginPATH
python3 -m venv .venv
source .venv/bin/activate
pip install -e .\[dev\]Optional environment variables:
export YT_TARGET_QUALITY=720
export YT_QUALITY_POLICY=strict
export YT_COOKIES_FROM_BROWSER=chrome
export YT_PO_TOKEN_ANDROID=...
export YT_PO_TOKEN_IOS=...Legacy YT_MIN_HEIGHT is still supported as a fallback for target quality.
Download a video:
youtube-downloader fetch "https://www.youtube.com/watch?v=dQw4w9WgXcQ"By default in text terminal mode, fetch shows an interactive quality selector (arrow keys + Enter).
Download to custom folder and JSON output:
youtube-downloader fetch "https://youtu.be/dQw4w9WgXcQ" --output-dir ./downloads --output jsonUse strict target quality:
youtube-downloader fetch "https://www.youtube.com/watch?v=dQw4w9WgXcQ" --target-quality 1080 --quality-policy strictDry-run without writing files:
youtube-downloader fetch "https://www.youtube.com/watch?v=dQw4w9WgXcQ" --dry-run --output jsonDisable interactive selector and use resolved/default quality directly:
youtube-downloader fetch "https://www.youtube.com/watch?v=dQw4w9WgXcQ" --no-interactive-qualityInspect runtime environment:
youtube-downloader doctorDescribe command contract:
youtube-downloader describe fetch0success2invalid input or unsupported URL3missing runtime dependency4inaccessible video or extractor auth failure5no format matched requested quality constraints6restricted/protected content or unavailable auth context7yt-dlp/ffmpeg/runtime error
- This utility downloads one video from the exact URL passed to
fetch. - The default output directory is
./downloads. --name-templateaccepts{title},{id},{uploader},{ext}placeholders or native yt-dlp template syntax.