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 prompteddocker run -it -v "$(pwd)/downloads:/downloads" yt_downIf 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 -v "$(pwd)/downloads:/downloads" -v "$(pwd)/cookies.txt:/cookiesftxt" yt_down
```.
## Cloud Deployment (CI/CD)
### Secure Cookie Setup
Cookies contain authentication credentials and should **never be committed to git**. Instead, use Google Cloud Secret Manager:
1. **Store cookies as a secret:**
```bash
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