A powerful, feature-rich YouTube downloader built in Python with support for individual videos, playlists, and advanced audio merging capabilities.
- Individual Video Downloads: Download single YouTube videos with format selection
- Playlist Support: Download entire playlists or specific video ranges
- Audio Merging: Automatically merge separate video and audio streams for optimal quality
- Format Selection: Choose from available video/audio formats with quality indicators
- Smart Quality Detection: Prioritizes formats with both video and audio
- Quality Control: Select single format for entire playlist downloads
- Clean Naming: Automatic filename sanitization and numbered playlist organization
- Progress Tracking: Real-time download progress with speed and ETA
- Error Handling: Robust error handling with graceful fallbacks
- Cross-Platform: Works on Windows, macOS, and Linux
- Single Folder Structure: All playlist videos stored in organized parent folders
- Numbered Naming: Videos named as "1. Title", "2. Title", etc.
- Clean Titles: Removes quotes, extra spaces, and replaces problematic characters
- Python 3.7 or higher
- pip (Python package installer)
pip install -r requirements.txtyt-dlp: YouTube video extraction and downloadingclick: Command-line interface frameworktqdm: Progress bars (optional)colorama: Cross-platform colored output (optional)
python -m ytd "https://www.youtube.com/watch?v=VIDEO_ID"python -m ytd "https://www.youtube.com/watch?v=VIDEO_ID" --format 136python -m ytd "https://www.youtube.com/watch?v=VIDEO_ID" --audio-onlypython -m ytd "https://www.youtube.com/watch?v=VIDEO_ID" --video-onlypython -m ytd "https://www.youtube.com/watch?v=VIDEO_ID" --list-formatspython -m ytd "https://www.youtube.com/playlist?list=PLAYLIST_ID"python -m ytd "https://www.youtube.com/playlist?list=PLAYLIST_ID" --playlistpython -m ytd "https://www.youtube.com/playlist?list=PLAYLIST_ID" --list-formatspython -m ytd "URL" --output "custom_folder"python -m ytd "URL" --quietpython -m ytd "URL" --config "config.json"When downloading, the tool presents an interactive menu:
Available Formats for: Video Title
============================================================
Video Formats:
[1] 720p mp4 - 15.2 MB [AUDIO]
[2] 1080p mp4 - 45.8 MB [NO AUDIO]
[3] 480p mp4 - 8.1 MB [AUDIO]
Audio Formats:
[4] Audio Only (mp3) - 3.2 MB
[5] Download All Formats
[6] Show More Info
[0] Cancel
For playlists, choose from:
Playlist Download Options:
============================================================
[1] Download entire playlist
[2] Download specific video range
[3] Download specific video
[4] Show detailed video list
[0] Cancel
downloads/
โโโ Video_Title_136.mp4
downloads/
โโโ Playlist_Title/
โโโ 1. First Video Title.mp4
โโโ 2. Second Video Title.mp4
โโโ 3. Third Video Title.mp4
โโโ ...
- Output Directory:
downloads/ - Format Priority: Combined video+audio streams first
- File Extension: MP4 for video, original for audio
- Progress Display: Enabled with speed and ETA
Create a config.json file:
{
"output_dir": "my_downloads",
"default_format": "136",
"quiet_mode": false
}- Modular Design: Separate modules for core, playlist, and CLI functionality
- Error Handling: Comprehensive error handling with user-friendly messages
- Logging: Detailed logging for debugging and monitoring
- Memory Efficient: Streams data without loading entire files into memory
- Video: MP4, WebM, AVI, MOV
- Audio: MP3, M4A, AAC, OGG
- Quality: Up to 4K resolution (depending on source)
- Codecs: H.264, VP9, AAC, Opus
- Video may be private, deleted, or region-restricted
- Check if the URL is accessible in your browser
- Some videos require age verification
- Use browser cookies or try different videos
- Use
--list-formatsto see available options - Some formats may not be available for all videos
- Check internet connection
- Verify sufficient disk space
- Try different format IDs
Enable verbose logging:
python -m ytd "URL" --verbose- Clone the repository
- Install development dependencies
- Run tests:
python -m pytest - Follow PEP 8 style guidelines
youtube-downloader/
โโโ ytd/
โ โโโ __init__.py # Package initialization
โ โโโ core.py # Core download functionality
โ โโโ playlist.py # Playlist handling
โ โโโ __main__.py # CLI interface
โ โโโ config.py # Configuration management
โโโ dev-docs/ # Development documentation
โโโ downloads/ # Default download directory
โโโ requirements.txt # Dependencies
โโโ README.md # This file
This project is open source and available under the MIT License.
- yt-dlp: Core YouTube extraction functionality
- Click: Command-line interface framework
- Python Community: For excellent libraries and tools
For issues, questions, or contributions:
- Create an issue on GitHub
- Check the troubleshooting section above
- Review the development documentation
Happy Downloading! ๐