Audio file auto-tagger
Project description
TruMusic
A command-line utility for downloading music from YouTube Music and automatically tagging audio files with metadata and album artwork.
Features
- Download albums from YouTube Music with a simple search or direct link
- Automatic ID3/MP4 tagging with artist, album, track info, and cover art
- Beautiful terminal UI with progress tracking
- Support for MP3 and M4A formats
- Retry logic for failed downloads
- Dry-run mode for testing
- Configurable via config file
Installation
pip install TruMusic
Requirements
- Python 3.10+
- FFmpeg (for audio conversion)
Installing FFmpeg
macOS:
brew install ffmpeg
Ubuntu/Debian:
sudo apt install ffmpeg
Windows: Download from ffmpeg.org and add to PATH.
Usage
Download an Album
Search by artist and album name:
trumusic -a "artist name" -t "album title"
Or use a direct YouTube Music album link:
trumusic -l "https://music.youtube.com/playlist?list=OLAK5uy_..."
Interactive Mode
Just run without arguments to be prompted:
trumusic
Options
-a, --artist Filter by artist name
-t, --title Filter by album title (optional)
-l, --link Direct YouTube Music album/playlist link
-f, --file_format Output format: mp3 or m4a (default: mp3)
-d, --dry_run Preview without downloading
-q, --quiet Skip prompts, use defaults
-v, --verbose Enable verbose logging
--cookies-from-browser Extract cookies from browser (local machine only)
Supported: chrome, firefox, safari, edge, brave, opera, chromium
Clean Existing Tags
Remove and normalize tags on existing audio files in the current directory:
trumusic_cleanup
Configuration
Create ~/.config/trumusic/config.toml for persistent settings:
# TruMusic Configuration
base_dest_dir = "~/Music/TruMusic"
oauth_file = "~/.config/ytmusicapi/oauth.json"
cookie_file = "~/.config/yt-dlp/cookies.txt"
default_format = "mp3"
max_retries = 3
request_timeout = 30
retry_delay = 5
# Browser to extract cookies from (for age-restricted content)
# Only works when running locally, not on remote servers
# cookies_from_browser = "chrome"
# OAuth credentials (REQUIRED)
# Get these from Google Cloud Console - see Authentication section below
oauth_client_id = "your-client-id.apps.googleusercontent.com"
oauth_client_secret = "your-client-secret"
Age-Restricted Content
Some tracks require YouTube authentication to download (age-restricted or explicit content). TruMusic will automatically detect these and provide instructions.
Option 1: Cookie File (works on remote servers)
-
Install a browser extension to export cookies:
- Chrome: "Get cookies.txt LOCALLY" or "EditThisCookie"
- Firefox: "cookies.txt"
-
Log into YouTube/YouTube Music in your browser
-
Export cookies for youtube.com to a file
-
Copy the file to
~/.config/yt-dlp/cookies.txt(or specify a custom path in config)
Option 2: Browser Cookies (local machine only)
Use the --cookies-from-browser flag:
trumusic -a "artist" --cookies-from-browser chrome
Or set it in your config file:
cookies_from_browser = "chrome"
Supported browsers: chrome, firefox, safari, edge, brave, opera, chromium
Authentication
TruMusic requires OAuth credentials to access YouTube Music. You'll need to set this up once:
1. Create OAuth Credentials
- Go to Google Cloud Console
- Create a new project (or select an existing one)
- Enable the YouTube Data API v3
- Go to Credentials > Create Credentials > OAuth client ID
- Select TVs and Limited Input devices as the application type
- Copy the Client ID and Client Secret
2. Configure TruMusic
Add your credentials to ~/.config/trumusic/config.toml:
oauth_client_id = "your-client-id.apps.googleusercontent.com"
oauth_client_secret = "your-client-secret"
3. Authenticate
On first run, TruMusic will open a browser window to authenticate with YouTube Music. The OAuth token is saved to ~/.config/ytmusicapi/oauth.json.
For age-restricted content, you may need to provide cookies:
- Export cookies from your browser using an extension
- Save to
~/.config/yt-dlp/cookies.txt
Development
Setup
git clone https://github.com/jacobtruman/TruMusic.git
cd TruMusic
pip install -e ".[dev]"
Running Tests
pytest
Linting
ruff check .
ruff format .
License
MIT License - see LICENSE for details.
Contributing
Contributions are welcome! Please open an issue or submit a pull request.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file trumusic-1.3.12.tar.gz.
File metadata
- Download URL: trumusic-1.3.12.tar.gz
- Upload date:
- Size: 22.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1822575638225e041ea138eab940bffcfc200e34764fe84e5278a9dd8e63ed77
|
|
| MD5 |
b77b126f543464dbe500c101cf209a8a
|
|
| BLAKE2b-256 |
34800c4c03b9c987bd49962fe9dc211a3c6242832633dc084baa4e4cec3912f4
|
Provenance
The following attestation bundles were made for trumusic-1.3.12.tar.gz:
Publisher:
python-publish.yml on jacobtruman/TruMusic
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
trumusic-1.3.12.tar.gz -
Subject digest:
1822575638225e041ea138eab940bffcfc200e34764fe84e5278a9dd8e63ed77 - Sigstore transparency entry: 1307864496
- Sigstore integration time:
-
Permalink:
jacobtruman/TruMusic@28efa0e1b3cf02b3967a1e53adcd74ab55ae5d57 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/jacobtruman
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@28efa0e1b3cf02b3967a1e53adcd74ab55ae5d57 -
Trigger Event:
push
-
Statement type:
File details
Details for the file trumusic-1.3.12-py3-none-any.whl.
File metadata
- Download URL: trumusic-1.3.12-py3-none-any.whl
- Upload date:
- Size: 19.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c36125c99a52c4d2915322528892497f58ab9a98bab9cd511eeb09fdcc27494
|
|
| MD5 |
c0a0a37ab1fbb10a644683f0e9d28bcf
|
|
| BLAKE2b-256 |
83fd64de337576c684b78b658c1b6f1dfe88848c35a4cfb44e78d18b1240ad18
|
Provenance
The following attestation bundles were made for trumusic-1.3.12-py3-none-any.whl:
Publisher:
python-publish.yml on jacobtruman/TruMusic
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
trumusic-1.3.12-py3-none-any.whl -
Subject digest:
4c36125c99a52c4d2915322528892497f58ab9a98bab9cd511eeb09fdcc27494 - Sigstore transparency entry: 1307864595
- Sigstore integration time:
-
Permalink:
jacobtruman/TruMusic@28efa0e1b3cf02b3967a1e53adcd74ab55ae5d57 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/jacobtruman
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@28efa0e1b3cf02b3967a1e53adcd74ab55ae5d57 -
Trigger Event:
push
-
Statement type: