A complete and interactive Python script to download YouTube videos.
- ✅ High-quality YouTube video downloads
- ✅ MP3 audio extraction
- ✅ Resolution choice (360p, 480p, 720p, 1080p)
- ✅ Interactive CLI interface with menu
- ✅ Command-line arguments
- ✅ Download progress display
- ✅ Detailed video information before download
- ✅ Robust error handling
- Python 3.6+
- pip
pip install yt-dlpFor audio extraction, FFmpeg is recommended (automatically installed by yt-dlp if needed).
python youtube_downloader.py --interactive
# or simply
python youtube_downloader.pyThe interactive mode provides a menu with the following options:
- Download video (best quality)
- Download as MP3 audio
- Download with resolution choice
- List available formats
- Change output directory
- Exit
# Simple download
python youtube_downloader.py "https://www.youtube.com/watch?v=VIDEO_ID"
# MP3 audio download
python youtube_downloader.py -f audio "https://www.youtube.com/watch?v=VIDEO_ID"
# Specific resolution download
python youtube_downloader.py -f 720 "https://www.youtube.com/watch?v=VIDEO_ID"
# Specify output directory
python youtube_downloader.py -o "/path/to/directory" "https://www.youtube.com/watch?v=VIDEO_ID"url: YouTube URL to download (optional in interactive mode)-f, --format: Download formatbest: Best available quality (default)audio: MP3 audio only360,480,720,1080: Specific video resolution
-o, --output: Custom output directory-i, --interactive: Launch interactive mode
By default, videos are downloaded to:
- Linux/Mac:
~/Downloads/YouTube/ - Windows:
C:\Users\[USERNAME]\Downloads\YouTube\
python youtube_downloader.py "https://www.youtube.com/watch?v=dQw4w9WgXcQ"python youtube_downloader.py -f audio "https://www.youtube.com/watch?v=dQw4w9WgXcQ"python youtube_downloader.py -iUse option 4 in interactive mode to see all available formats for a video.
The script can be called multiple times or integrated into a bash script for batch downloads.
The script automatically handles:
- Invalid URLs
- Unavailable videos
- Network issues
- Audio conversion errors
- Insufficient permissions
- The script does not collect any personal data
- URLs are processed locally only
- No connection to third-party servers (except YouTube)
This project is provided as-is, without warranty.
For issues or suggestions, first check:
- That yt-dlp is up to date:
pip install --upgrade yt-dlp - That Python 3.6+ is installed
- That the YouTube URL is valid and accessible
Script created by Cline - Autonomous Developer