A powerful, AI-driven tool designed to organize, tag, and manage your classical music collection. This script uses the OpenRouter API (Accessing models like Google Gemini, GPT-5.x, etc.) to intelligently analyze filenames and contexts, generating accurate and standardized metadata for your FLAC files.
- AI-Powered Metadata Tagging: automatically extracts Composer, Work, Movement, Performers, and more from filenames using advanced LLMs.
- Intelligent Renaming: Renames files to a clean, searchable format (e.g.,
Track - Composer - Work - Movement - Performer). - Format Conversion: Automatically converts non-FLAC audio files (MP3, M4A, WAV, etc.) to FLAC using
ffmpeg. - Metadata Audit & Repair: Scans your entire library to verify consistency, identify missing tags, and suggest improvements.
- Cover Art Generation: Generates unique, minimalist, and "luxurious" cover art for tracks missing artwork.
- Library Statistics: meaningful insights into your collection, including metadata coverage, top composers, and missing fields.
- Interactive TUI: A beautiful terminal user interface built with
richfor easy navigation.
Before running the script, ensure you have the following installed:
- Python 3.8+
- FFmpeg: Required for audio conversion.
brew install ffmpeg # macOS (Homebrew) sudo apt install ffmpeg # Ubuntu/Debian
- OpenRouter API Key: You need an API key from OpenRouter to power the AI tagging.
-
Clone this repository or download the
music.pyscript. -
Install the required Python dependencies:
pip install mutagen openai rich pillow
Set your OpenRouter API key as an environment variable:
export OPENROUTER_API_KEY="your-api-key-here"You can add this line to your shell configuration file (~/.zshrc or ~/.bashrc) to make it permanent.
Run the script by providing the path to your music folder:
python3 music.py /path/to/your/music/folder- Process New Files: Scans for untagged FLAC files and converts non-FLAC files. Recommended for new additions to your library.
- Metadata Audit & Repair: A deep scan of your entire library. Useful for fixing inconsistent naming or filling in gaps in your collection.
- View Statistics: Shows how much of your library is tagged, top composers, and disk usage.
- Settings: Change the AI model used for analysis (default:
google/gemini-3-flash-preview). - Generate Cover Art: Creates programmatic, geometric cover art for files without embedded images.
You can change the default AI model in the Settings menu or by modifying the DEFAULT_MODEL variable in the script.
- Backup: The script creates backups of converted files in
~/Desktop/music_backups/before replacing them. - Safety: "Dry Run" modes are available for most operations, allowing you to preview changes before applying them.
Happy Listening! ♪ ♫