Small cross-platform CLI script to download YouTube videos or audio using yt-dlp.
- Works on macOS, Linux, and Windows
- Auto platform detection (
bash + uname, fallback to Windows profile) - Video download with target max quality (example: 720p, 1080p)
- Audio-only mode with MP3 conversion
- Auto-creates output directory if missing
- Compatibility profiles:
auto,mac,windows,linux,universal
- Python 3.10+
ffmpeg(recommended; required for merge/conversion)- Python package:
yt-dlp
Install Python deps:
pip install -r requirements.txtInstall ffmpeg (examples):
- macOS (Homebrew):
brew install ffmpeg - Ubuntu/Debian:
sudo apt install ffmpeg - Windows (winget):
winget install Gyan.FFmpeg
python3 youtube_downloader.py "https://www.youtube.com/watch?v=VIDEO_ID"Output is saved in ./Download by default.
python3 youtube_downloader.py "https://www.youtube.com/watch?v=VIDEO_ID"python3 youtube_downloader.py "https://www.youtube.com/watch?v=VIDEO_ID" --quality 720python3 youtube_downloader.py "https://www.youtube.com/watch?v=VIDEO_ID" --audio-onlypython3 youtube_downloader.py "https://www.youtube.com/watch?v=VIDEO_ID" --output-dir DownloadsScriptpython3 youtube_downloader.py "https://www.youtube.com/watch?v=VIDEO_ID" --compat-mode mac
python3 youtube_downloader.py "https://www.youtube.com/watch?v=VIDEO_ID" --compat-mode windows
python3 youtube_downloader.py "https://www.youtube.com/watch?v=VIDEO_ID" --compat-mode linux
python3 youtube_downloader.py "https://www.youtube.com/watch?v=VIDEO_ID" --compat-mode universal- macOS: profile
macprefersavc1 + mp4a, usually best for QuickTime. - Windows: profile
windowsprefersh264/avc1 + mp4afor broad player support. - Linux: profile
linuxusesmp4 + m4apreference where possible.
ffmpeg not found: install ffmpeg, then retry.- Download skipped because file already exists: use another
--output-dir. - Some yt-dlp warnings about JS runtime can appear depending on extractor updates.
GitHub Actions workflow is included at:
.github/workflows/ci.yml
It runs:
- syntax compile check (
py_compile) - CLI smoke check (
--help) - on macOS, Linux, and Windows (Python 3.10/3.11/3.12)
Before pushing public release:
- Update
CHANGELOG.md. - Verify local checks:
python3 -m py_compile youtube_downloader.pyandpython3 youtube_downloader.py --help. - Ensure
README.mdand CLI options are aligned. - Commit with a clear message.
- Tag a version (example:
v1.0.0) after first release commit.
See CONTRIBUTING.md.
Only download content if you have the right to do so and if local laws / platform terms allow it.
This project is licensed under the MIT License. See LICENSE.