Youtube downloader

From daymade/claude-code-skills · View interactive version

Youtube downloader is an AI agent skill from the GitHub repository daymade/claude-code-skills. Fetch existing YouTube transcripts/subtitles or archive spoken video content as text, and download YouTube videos/audio or HLS streams (m3u8) with yt-dlp and ffmpeg. Use for transcript/subtitle retrieval, text-first video archiving, video/audio downloads, protected streams with authentication header

How to use this skill

Skill file

YouTube Downloader

Overview

Enable reliable video and audio downloads from YouTube and HLS streaming platforms (Mux, Vimeo, etc.) using yt-dlp and ffmpeg. This skill provides workflows for:

Goal Split: File vs. Text (Read First)

Before downloading anything, classify the request:

The text-first route never blocks a file request: when the user wants the file, download it with the unchanged flow below.

Non-Technical User Experience (Default)

Assume the user is non-technical. Do not ask them to run commands. Execute everything yourself and report progress in plain language. Avoid mentioning tooling unless the user asks.

Default flow:

  1. Ask for the URL (if not provided).
  2. Fetch video metadata (title/uploader/duration/thumbnail) and confirm it matches the user's intent.
  1. Offer simple choices (video vs. audio-only, quality, subtitles, save location).
  2. Proceed with sensible defaults if the user does not specify:
  1. Download and report the final file path, file size, and resolution (if video).

Offer choices in user-friendly terms:

Always render the thumbnail when available:

Ask before doing extra work:

Legal/Safety reminder (brief):

Response template (use plain language, no commands):

![Thumbnail](THUMBNAIL_URL)

Title: …
Channel: …
Duration: …

I can help you:
1) Download the video (best quality, MP4)
2) Download audio only (MP3)
3) Pick a specific quality (1080p/720p/480p/360p)
4) Include subtitles (if available)

Where should I save it? (Default: Downloads folder)

If the user says “just download”:

Reliable Download SOP (Internal)

Read the download SOP before retrying a failure. Start with the current yt-dlp default clients and the existing network configuration. Do not require a provider, switch to Android, or extract browser cookies merely to begin a download.

Agent Execution Checklist (Internal)

When to Use This Skill

This skill should be invoked when users:

Prerequisites

1. Verify yt-dlp Installation (Run this yourself)

which yt-dlp
yt-dlp --version

If missing or a current extraction diagnostic requires an update, obtain any missing install/upgrade authorization, then use the existing installation owner:

brew upgrade yt-dlp  # macOS
# or
pip install --upgrade yt-dlp  # Cross-platform

Check the current EJS setup guide for the JavaScript runtime and challenge-solver requirements of the installed distribution. An installed Node binary may need explicit --js-runtimes node; do not treat an EJS/nsig failure as a PO Token failure.

2. Check Current Quality Access (Run this yourself)

Before downloading, check available formats:

yt-dlp -F "https://youtu.be/VIDEO_ID"

Compare the listed media streams with the requested quality. If only a low-resolution format appears, inspect extraction/runtime warnings and the source availability before choosing recovery.

High-Quality Download Workflow

Step 1: Try the Native Client Selection

Keep player_client unset unless there is a specific diagnostic or explicit request. The official extractor guide describes yt-dlp's default attempt with clients that do not require tokens. Available formats depend on the video, account, client, network and current YouTube enforcement.

Step 2: Download and Escalate Only When Needed

# Download best quality up to 1080p
scripts/download_video.py "VIDEO_URL" --quality 1080p

# Download best available quality
scripts/download_video.py "VIDEO_URL"

# After an explicit token requirement, with setup already authorized
scripts/download_video.py "VIDEO_URL" --auto-po-token

For installation and provider-specific recovery, load PO Token setup. Do not infer a provider requirement from resolution alone.

Step 3: Verify Download Quality

# Check video resolution
ffprobe -v error -select_streams v:0 -show_entries stream=width,height,codec_name -of default=noprint_wrappers=1 video.mp4

Expected output for 1080p:

codec_name=vp9
width=1920
height=1080

Authorized Browser Cookies Method

Use cookies when the content requires the authorized account or a bot check persists, after cookie permission is granted. Cookies authenticate a session; they do not replace a missing PO Token:

# Firefox
yt-dlp --cookies-from-browser firefox -f "bestvideo[height<=1080]+bestaudio/best" "VIDEO_URL"

# Chrome
yt-dlp --cookies-from-browser chrome -f "bestvideo[height<=1080]+bestaudio/best" "VIDEO_URL"

Benefits: Access to age-restricted and members-only content.

Requirements:

Common Tasks

Audio-Only Download (Run this yourself)

Extract audio as MP3:

yt-dlp -x --audio-format mp3 "VIDEO_URL"

Custom Output Directory (Run this yourself)

yt-dlp -P ~/Downloads/YouTube "VIDEO_URL"

Download with Subtitles (Run this yourself)

yt-dlp --write-subs --sub-lang en "VIDEO_URL"

Playlist Download (Run this yourself)

yt-dlp -f "bestvideo[height<=1080]+bestaudio/best" "PLAYLIST_URL"

Convert WebM to MP4 (Run this yourself)

YouTube high-quality downloads often use WebM format (VP9 codec). Convert to MP4 for wider compatibility:

# Check if ffmpeg is installed
which ffmpeg || brew install ffmpeg  # macOS

# Convert WebM to MP4 with good quality settings
ffmpeg -i "video.webm" -c:v libx264 -preset medium -crf 23 -c:a aac -b:a 128k "video.mp4"

Parameters explained:

Tip: Conversion maintains 1080p resolution and provides ~6x encoding speed on modern hardware.

Troubleshooting Quick Reference

Missing Quality / Only Images / Requested Format Not Available

Inspect -F, the selected format expression, current yt-dlp/EJS/runtime warnings and source availability. These messages have multiple causes. Enter provider setup only when a failed extraction or media request also names a missing/required PO Token. Do not install a provider because a requested height or format ID is absent.

Sign in to Confirm You’re Not a Bot

Check that the intended proxy/network is in use. If the challenge persists and cookies are needed, obtain cookie authorization, retain that session, and retry. Stop with the exact authorization gap if it is unavailable; do not silently read browser cookies.

nsig / JavaScript Challenge Failure

Check the installed yt-dlp version and the EJS runtime and solver instructions. Repair the diagnosed prerequisite within authorization. Android or AndroidVR can be selected explicitly for a bounded diagnostic, but neither is the default recovery or a guaranteed solution.

403 / SSL EOF / Fragment Errors

Distinguish a media 403 from TLS, timeout, proxy and provider-health errors. A generic 403 does not prove a Token requirement. Check the network path first for SSL/timeout failures; retry only after a relevant change. The wrapper's single progressive retry applies to 403/fragment failures with quality presets, and may reduce quality.

Slow Downloads or Network Errors

For users in China or behind restrictive proxies:

PO Token Warning (Harmless)

WARNING: android client https formats require a GVS PO Token

Action: A successful, verified download needs no repair for an unused-client warning. On failure, read the full diagnostic and actual formats before choosing a token branch.

Bundled Script Reference

scripts/download_video.py

Use this wrapper for native-client downloads and bounded diagnostic recovery. It does not install/start providers or read cookies by default. Execute it yourself and report the verified file.

Basic usage:

scripts/download_video.py "VIDEO_URL"

Arguments:

Quality Expectations

Do not promise a resolution based on a provider/client/cookie combination. Request the desired quality, inspect available formats, and verify the actual downloaded file. A successful high-resolution download without new provider setup proves only that input and environment; installed plugins or configuration may still contribute. A provider cannot create a resolution absent from the source.

HLS Stream Downloads (m3u8)

For streaming platforms like Mux, Vimeo, and other HLS-based services, use ffmpeg as the primary tool. These streams often require authentication headers that yt-dlp may not handle correctly.

Identifying HLS Streams

HLS streams use .m3u8 playlist files:

Download Workflow

Step 1: Obtain the Stream URL

Get the m3u8 URL from the video source. For protected streams:

  1. Open browser DevTools → Network tab
  2. Play the video
  3. Filter for "m3u8" to find the playlist URLs
  4. Copy the rendition URL (usually contains quality info like "rendition.m3u8")
Step 2: Identify Required Headers

Many CDNs require authentication headers:

Check the Network tab to see which headers the browser sends.

Step 3: Download with ffmpeg

Use ffmpeg with the -headers flag for protected streams:

ffmpeg -headers "Referer: https://example.com/" \
  -protocol_whitelist file,http,https,tcp,tls,crypto,httpproxy \
  -i "https://cdn.example.com/path/rendition.m3u8?params" \
  -c copy -bsf:a aac_adtstoasc \
  output.mp4

Key parameters:

Common header patterns:

# Single header
-headers "Referer: https://example.com/"

# Multiple headers
-headers "Referer: https://example.com/" \
-headers "User-Agent: Mozilla/5.0..."

# Alternative syntax
-headers $'Referer: https://example.com/\r\nUser-Agent: Mozilla/5.0...'

Handling Separate Audio/Video Streams

Some platforms (like Mux) deliver audio and video separately:

  1. Download audio stream:
ffmpeg -headers "Referer: https://example.com/" \
  -protocol_whitelist file,http,https,tcp,tls,crypto,httpproxy \
  -i "https://cdn.example.com/audio/rendition.m3u8" \
  -c copy audio.m4a
  1. Download video stream:
ffmpeg -headers "Referer: https://example.com/" \
  -protocol_whitelist file,http,https,tcp,tls,crypto,httpproxy \
  -i "https://cdn.example.com/video/rendition.m3u8" \
  -c copy video.mp4
  1. Merge streams:
ffmpeg -i video.mp4 -i audio.m4a -c copy merged.mp4

Troubleshooting HLS Downloads

403 Forbidden Errors

Cause: Missing or incorrect authentication headers.

Solution:

  1. Verify Referer header matches the video source website
  2. Check if additional headers (Origin, User-Agent) are needed
  3. Ensure the m3u8 URL includes all query parameters from browser
yt-dlp Stuck on Cookie Extraction

Symptom: Extracting cookies from chrome hangs indefinitely.

Solution: Use ffmpeg directly instead of yt-dlp for HLS streams.

Protocol Not Whitelisted

Error: Protocol 'https' not on whitelist 'file,crypto,data'

Solution: Add -protocol_whitelist file,http,https,tcp,tls,crypto,httpproxy

Empty Segments or No Streams

Cause: Expired signatures in the m3u8 URLs.

Solution:

  1. Get fresh URLs from browser DevTools
  2. Download immediately after obtaining URLs
  3. Look for rendition URLs with updated signature parameters

Performance Tips

Further Reading

Next Step: Text From the Video

Two situations, two routes:

Download complete: [filename]

If you need the spoken content as text, I can transcribe it for you.

Options:
A) Transcribe with /daymade-audio:asr-transcribe-to-text (Recommended for speech-to-text)
B) No thanks — I just needed the video file
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.