Skip to main content

Audio file auto-tagger

Project description

CI/CD PyPI version Python 3.10+

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)

  1. Install a browser extension to export cookies:

    • Chrome: "Get cookies.txt LOCALLY" or "EditThisCookie"
    • Firefox: "cookies.txt"
  2. Log into YouTube/YouTube Music in your browser

  3. Export cookies for youtube.com to a file

  4. 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

Authentication is optional for most content. TruMusic will prompt you to set up authentication only when downloading age-restricted or members-only content.

When Authentication is Needed

If you encounter age-restricted tracks, TruMusic will offer to set up browser authentication:

  1. Open https://music.youtube.com and log in
  2. Open Developer Tools (F12 or Cmd+Option+I)
  3. Go to the Network tab
  4. Click any request to music.youtube.com
  5. Find Cookie in Request Headers and copy the value
  6. Paste when prompted

The credentials are saved to ~/.config/ytmusicapi/browser.json and are valid for ~2 years.

Alternative: Cookie File

You can also provide cookies via a file:

  1. Export cookies from your browser using an extension
  2. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

trumusic-1.4.4.tar.gz (25.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

trumusic-1.4.4-py3-none-any.whl (22.3 kB view details)

Uploaded Python 3

File details

Details for the file trumusic-1.4.4.tar.gz.

File metadata

  • Download URL: trumusic-1.4.4.tar.gz
  • Upload date:
  • Size: 25.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for trumusic-1.4.4.tar.gz
Algorithm Hash digest
SHA256 8fda3820cea0819423a6d8800b74cc232ddbdb358b24184b876b0a1dcb2606cc
MD5 7bfa229173c5b14a76311bc6dd2520a5
BLAKE2b-256 757d7c0fc514b84cc8dc82d9cf5d2e5e181e48980da7aaf72f5adb715cf9c001

See more details on using hashes here.

Provenance

The following attestation bundles were made for trumusic-1.4.4.tar.gz:

Publisher: python-publish.yml on jacobtruman/TruMusic

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file trumusic-1.4.4-py3-none-any.whl.

File metadata

  • Download URL: trumusic-1.4.4-py3-none-any.whl
  • Upload date:
  • Size: 22.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for trumusic-1.4.4-py3-none-any.whl
Algorithm Hash digest
SHA256 2f9a6fbb7a58664d1543ca1152276d65ef770a6eb386f9c1d6b42542d8066f01
MD5 ab864bd6122011991c5df3b0b95ba08e
BLAKE2b-256 d643b3688c5e6ba85e5d5a748ca5b9ceb9eab1e73b8f25217c20a3892dec35e6

See more details on using hashes here.

Provenance

The following attestation bundles were made for trumusic-1.4.4-py3-none-any.whl:

Publisher: python-publish.yml on jacobtruman/TruMusic

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page