YouTube Video Downloader
Download YouTube videos with full control over quality and format settings.
Requirements
- Python 3.8+
- yt-dlp (auto-installs if not present)
Quick Start
The simplest way to download a video:
yt-dlp "https://www.youtube.com/watch?v=VIDEO_ID"
This downloads the video in best available quality.
Options
Quality Settings
Use -f to specify video quality:
# Best quality (default)
yt-dlp "URL"
# Specific resolution
yt-dlp -f "bestvideo[height<=1080]+bestaudio/best[height<=1080]" "URL"
yt-dlp -f "bestvideo[height<=720]+bestaudio/best[height<=720]" "URL"
yt-dlp -f "bestvideo[height<=480]+bestaudio/best[height<=480]" "URL"
Format Options
# MP4 format
yt-dlp -f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]" "URL"
# WebM format
yt-dlp -f "bestvideo[ext=webm]+bestaudio[ext=webm]/best[ext=webm]" "URL"
Audio Only
Download only audio as MP3:
yt-dlp -x --audio-format mp3 "URL"
Custom Output Directory
yt-dlp -o "/path/to/directory/%(title)s.%(ext)s" "URL"
Complete Examples
- Download video in 1080p as MP4:
yt-dlp -f "bestvideo[height<=1080][ext=mp4]+bestaudio[ext=m4a]/best[height<=1080]" "https://www.youtube.com/watch?v=VIDEO_ID"
- Download audio only as MP3:
yt-dlp -x --audio-format mp3 "https://www.youtube.com/watch?v=VIDEO_ID"
- Download with custom filename:
yt-dlp -o "%(title)s - %(upload_date)s.%(ext)s" "URL"
- Download playlist:
yt-dlp -o "%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s" "PLAYLIST_URL"
Useful Options
| Option | Description |
|---|---|
-o |
Output template |
-f |
Format selection |
-x |
Extract audio |
--audio-format |
Audio format (mp3, wav, etc.) |
--list-formats |
List available formats |
--no-playlist |
Download single video from playlist |
--write-thumbnail |
Save thumbnail image |
--write-subs |
Download subtitles |
--sub-lang |
Subtitle language (e.g., "en", "ja") |
Installation
If yt-dlp is not installed:
# macOS
brew install yt-dlp
# pip
pip install yt-dlp
# Update existing installation
yt-dlp -U
Important Notes
- Video filename is automatically generated from the video title
- Higher quality videos may take longer to download and use more disk space
- Some videos may have download restrictions
- Use responsibly and respect copyright