A simple CLI tool to download YouTube audio as MP3, written in Rust. Uses yt-dlp under the hood.
Rust here is solely for learning purposes!
- Downloads YouTube videos as MP3 audio
- Supports browser cookies for bot detection bypass
- Docker support for easy reproducibility
- Cross-platform (Windows, Linux, macOS)
winget install yt-dlppip install yt-dlp
# or
brew install yt-dlp ffmpegcd yt_down
cargo build --releaseThe binary will be at target/release/yt_down.
cd yt_down
docker build -t yt_down ../yt_down
# Then paste a YouTube URL when promptedThe image defaults to the web server. For the CLI, override the entrypoint:
docker run -it --entrypoint yt_down --rm -v "$(pwd)/downloads:/downloads" yt_downFor the web server:
docker run -p 8080:8080 --rm yt_downThen open http://localhost:8080.
If YouTube blocks downloads, you can provide cookies:
- Export cookies from your browser using the "Get cookies.txt LOCALLY" extension
- Run with cookies mounted:
docker run -it --entrypoint yt_down --rm -v "$(pwd)/downloads:/downloads" -v "$(pwd)/cookies.txt:/cookies.txt" yt_downCookies contain authentication credentials and should never be committed to git. Instead, use Google Cloud Secret Manager:
-
Store cookies as a secret:
gcloud secrets create youtube-cookies --data-file=cookies.txt
-
Grant Cloud Build access to the secret:
gcloud projects add-iam-policy-binding $PROJECT_ID \ --member=serviceAccount:$PROJECT_NUMBER@cloudbuild.gserviceaccount.com \ --role=roles/secretmanager.secretAccessor
gcloud builds submit --config cloudbuild.yamlCreate a Cloud Build trigger for automatic deployment on push:
gcloud builds triggers create github \
--repo-name=yt_down \
--repo-owner=YOUR_GITHUB_USERNAME \
--branch-pattern=main \
--build-config=cloudbuild.yaml- Prompts for a YouTube URL
- Extracts audio using yt-dlp
- Converts to MP3 using ffmpeg
- Saves with the video title as filename