Skip to main content

Friendly command-line music-metadata editor and Python library

Project description

mudio

mudio is a powerful, friendly command-line music metadata editor and Python library. It provides a unified API for handling metadata across MP3, FLAC, M4A, and more, making batch processing and automation simple and safe.

Features

  • Unified API: Write code once, run it on MP3, FLAC, M4A, WAV, OGG, OPUS, WMA, and WavPack.
  • Batch Processing: robust CLI for processing thousands of files.
  • Parallel Execution: Automatically uses multi-threading for large batches.
  • Safety First: Built-in backup system, dry-run mode, and careful validation.
  • Powerful Operations:
    • Find & Replace: Regex-supported search and replace in tags.
    • Mass Edits: Set, overwrite, append, prefix, or clear tags.
    • Filtering: Apply changes only to files matching specific criteria (e.g. artist="The Beatles").

Supported Formats

  • MP3 (.mp3) - ID3v2.3/v2.4
  • FLAC (.flac) - Vorbis Comments
  • M4A / MP4 (.m4a, .mp4) - MP4 Tags
  • Ogg Vorbis (.ogg)
  • Opus (.opus)
  • WAV (.wav)
  • Windows Media Audio (.wma)
  • WavPack (.wv)

Installation

pip install mudio

CLI Usage

mudio is designed for efficient batch operations.

Basic Commands

# View metadata (truncated if long)
mudio song.mp3 --operation print

# Set Album
mudio *.mp3 --operation set --fields album --value "New Album"

# Overwrite Title
mudio song.flac --operation set --fields title --value "My Song"

Advanced Batch Operations

# Regex Find & Replace (Fix features)
# Changes "feat." -> "ft." in title and artist
mudio /music --recursive \
  --operation find-replace --find "feat\." --replace "ft." --regex \
  --fields title,artist

# Append to Comment
mudio *.m4a --operation append --fields comment --value " [Remastered]"

# Filtered Processing
# Only add "Rock" genre to tracks by "Led Zeppelin"
mudio /library --recursive \
  --filter "artist=Led Zeppelin" \
  --operation set --fields genre --value "Rock"

Safety Features

# Dry Run (See what would happen without modifying files)
mudio *.mp3 --operation set --fields album --value "Test" --dry-run

# Create Backups (Kept by default in ./backups/)
mudio *.flac --operation clear --fields comment --backup ./backups

# Delete backups after successful operation (to save space)
mudio *.mp3 --operation set --fields album --value "New" --backup ./backups --delete-backups

Python Library Usage

mudio provides a Pythonic wrapper around mutagen for scripts and tools.

from mudio import SimpleMusic

# Reading metadata (extended mode by default - includes custom fields)
with SimpleMusic("song.flac") as sm:
    fields = sm.read_fields()  # Default: schema='extended'
    print(fields)
    # {'artist': ['The Band'], 'title': ['The Song'], ...}

# Read with different schemas
with SimpleMusic("song.mp3") as sm:
    canonical = sm.read_fields(schema='canonical')  # Only standard fields
    raw = sm.read_fields(schema='raw')  # Format-specific keys (TIT2, TPE1, etc.)
    extended = sm.read_fields(schema='extended')  # Standard + custom fields

# Writing
with SimpleMusic("song.mp3") as sm:
    sm.write_fields({
        'title': ['New Title'],
        'genre': ['Pop', 'Rock']  # Multi-value support
    })

# Error handling is managed by the context manager

Environment Variables

You can configure mudio's default behavior using environment variables:

  • MUDIO_SCHEMA: Set default schema for reading metadata (canonical, extended, or raw). Default: extended.
  • MUDIO_MAX_WORKERS: Default thread count for parallel processing.
  • MUDIO_BACKUP_DIR: Default backup location.
  • MUDIO_VERBOSE: Default verbosity (0 or 1).
# Example: Use extended schema by default (canonical + custom fields)
export MUDIO_SCHEMA=extended
python your_script.py

Behavior Notes

MP3 Comment and Performer Handling

To ensure metadata consistency, mudio applies specific logic when reading and writing MP3 comments (COMM) and Performer tags (TPE3 / TXXX:PERFORMER):

  • Reading:
    • Identical Frames: If multiple frames satisfy the same description/type and have identical content (case-sensitive), they are deduplicated (e.g. ['a'] + ['a'] -> ['a']).
    • Intra-Frame Duplicates: Duplicates within a single frame are preserved (e.g. ['a', 'b', 'b'] -> ['a', 'b', 'b']).
    • Distinct Frames: Different frames are preserved (e.g. ['a'] + ['b'] -> ['a', 'b']).
  • Writing:
    • Comments: All comment values are collapsed into a single COMM frame.
    • Performers: All performer values are written to standard TPE3 frames (and TXXX:PERFORMER if needed), ensuring no duplication between standard and custom tag fields.

Comparison with Alternatives

vs. Mutagen

  • Mutagen is the low-level library that mudio uses. It is powerful but requires learning different APIs for ID3, Vorbis, and MP4 tags.
  • mudio abstracts these differences. Use mudio if you want a simple, unified API (e.g. sm.write_fields({'title': ...}) works on everything). Use mutagen if you need byte-level control or support for obscure frame types.

vs. music_tag

  • music_tag is a library primarily for Python scripts, offering a dictionary-like interface. It is excellent for simple script usage.
  • mudio offers similar library features but includes a robust CLI for batch processing, filtering, and safety operations (backups, dry-runs) out of the box.

vs. Beets

  • Beets is a complete library manager with a centralized database, autotagger, and plugin system. It implies a workflow where it "owns" your library.
  • mudio is a stateless tool. It modifies files directly without a database. Use mudio for quick fixes, batch scripting, or if you prefer managing your file structure manually.

vs. Picard

  • MusicBrainz Picard is a GUI application focused on matching files to the MusicBrainz database.
  • mudio is a CLI/Library tool. It's better for automation, headless servers, or mass-editing tags based on patterns rather than database matching.

vs. EyeD3

  • EyeD3 is excellent but specific to MP3/ID3.
  • mudio supports FLAC, M4A, OGG, and more with the same commands.

Development

# Install dependencies
pip install -e ".[dev]"

# Run tests
pytest

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

mudio-2.1.0.tar.gz (42.0 kB view details)

Uploaded Source

Built Distribution

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

mudio-2.1.0-py3-none-any.whl (38.5 kB view details)

Uploaded Python 3

File details

Details for the file mudio-2.1.0.tar.gz.

File metadata

  • Download URL: mudio-2.1.0.tar.gz
  • Upload date:
  • Size: 42.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for mudio-2.1.0.tar.gz
Algorithm Hash digest
SHA256 85369985c95dbb0679f7dfb14b51bc2b7daae68f5689c371805b81b3454d06bf
MD5 21f0c8153687106c70f4bb11a6f5fe12
BLAKE2b-256 ec678f7a5e68a169e44641949fc72c70cfb1ffe2bb582f7091a5f56c4cc809e9

See more details on using hashes here.

File details

Details for the file mudio-2.1.0-py3-none-any.whl.

File metadata

  • Download URL: mudio-2.1.0-py3-none-any.whl
  • Upload date:
  • Size: 38.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for mudio-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 82f847e88155acaee0cda108876e572fd3b0a7274e07b324cd7e3373105e1268
MD5 0e508424c802081e0a5d66f9df551dd4
BLAKE2b-256 a9e838e189d5f7d9790a6c93b5db43c2566f44267c69fac984797566870cbcf7

See more details on using hashes here.

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