Music library management tool for organizing and downloading high-quality audio
Project description
Magapy - Music Library Management Tool
A comprehensive Python tool for managing music libraries, with a focus on high-quality audio files. Magapy helps you organize, deduplicate, and maintain a well-structured music collection.
Features
- Multi-source Downloads: Download tracks from Qobuz and Tidal
- Quality Analysis: Automatically detect and categorize audio quality (HiRes, MQA, Standard)
- Duplicate Detection: Find and manage duplicate tracks based on audio content
- Library Organization: Keep your music collection tidy and well-structured
- Beets Integration: Seamless integration with the beets music library manager
- Metadata Management: Extract and update audio file metadata
- Audio file analysis
- Integration with MusicBrainz and other music databases
- Support for various audio formats
Installation
From PyPI
pip install magapy
From Source
-
Clone the repository:
git clone https://github.com/geooooooorges/magapy.git cd magapy
-
Install the package:
pip install -e .
Configuration
Required Third-Party Tools
Magapy depends on external tools for downloading content:
1. qobuz-dl (for Qobuz downloads)
Install qobuz-dl:
pip install qobuz-dl
Configure qobuz-dl with your credentials:
qobuz-dl config init
# Follow the interactive prompts to enter your Qobuz credentials
2. tidal-wave through "UVX" (for Tidal downloads)
Install UVX for Tidal downloads:
pip install uvx
Configure Tidal authentication:
uvx tidal-wave auth
# Follow the interactive prompts to log in to Tidal
Magapy Configuration
Magapy offers flexible configuration through environment variables, config files, or command-line options:
1. Environment Variables
Set environment variables for quick configuration:
# Set core directories
export MUSIC_DIR="/path/to/your/music"
export DOWNLOAD_DIR="/path/to/downloads"
export REVIEW_DIR="/path/to/review/directory"
# Set API keys
export ACOUSTID_API_KEY="your-acoustid-api-key"
export MUSICBRAINZ_API_KEY="your-musicbrainz-api-key"
2. Configuration File
Create a configuration file at one of these locations:
./magapy.ini(current directory)~/.config/magapy/config.ini(user config directory)/etc/magapy/config.ini(system-wide)
Generate an example configuration:
magapy config --create-example
Example config file structure:
[paths]
music_dir = /path/to/your/music/library
download_dir = /path/to/downloads
review_dir = /path/to/review/directory
[settings]
dry_run = false
detailed_logging = true
use_beets = false
[api_keys]
acoustid = your_acoustid_api_key
musicbrainz = your_musicbrainz_api_key
3. Command Line Options
Override configuration with command-line options:
magapy download "https://play.qobuz.com/track/12345678" --download-dir ~/Downloads/NewMusic
Usage
Command Line Interface
Magapy provides a simple command line interface:
# Download a track
magapy download "https://play.qobuz.com/track/12345678"
# Using shorter alias
magapy d "https://play.qobuz.com/track/12345678"
# Review library for duplicates
magapy review --music-dir /path/to/music
# Update the track database
magapy update
# Analyze library and generate statistics
magapy analyze --output stats.json --format json
# Extract cover art from files
magapy cover /path/to/audio.flac --output-dir /path/to/covers --resize 500
Direct URL Handling
For convenience, you can also download directly by providing a URL:
magapy "https://play.qobuz.com/track/12345678"
Beets Integration
Magapy integrates with Beets for advanced library management:
# Process downloads with beets
magapy download "https://play.qobuz.com/track/12345678" --use-beets --beets-move
Basic usage
import magapy
# Analyze your music library
magapy.analyze_library("path/to/music/library")
Command line usage
magapy-cli analyze "path/to/music/library"
Quality Ranking System
Magapy categorizes audio files by quality:
- HiRes (Rank 3): Sample rate ≥ 96kHz or bitrate ≥ 2500kbps
- MQA (Rank 2): Contains MQA encoding
- Standard (Rank 1): Standard CD quality or less
Troubleshooting
1. Download Issues
- Check Credentials: Ensure your Qobuz and Tidal credentials are correct.
- Verify Links: Make sure the Qobuz/Tidal links are valid and accessible.
- Network Connection: Check your internet connection.
- Rate Limiting: If downloads fail intermittently, you may be hitting rate limits. Try again later.
2. Beets Integration
- Configuration: Ensure your Beets configuration is correct (check
~/.config/beets/config.yaml). - Plugin Issues: If certain Beets plugins are not working, make sure they are installed and configured correctly.
- Library Path: Verify that the
directory:setting in your Beets config points to the correct music library path.
3. General Issues
- Permissions: Ensure you have the necessary permissions to read/write files in your music and download directories.
- Dependencies: Make sure all required Python packages are installed (
pip install -r requirements.txt). - Logging: Check the log files for detailed error messages.
Requirements
- Python 3.7+
- Dependencies listed in requirements.txt
Development
Testing
Run tests with pytest:
pytest
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project Structure
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 magapy-0.1.2.tar.gz.
File metadata
- Download URL: magapy-0.1.2.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0de483834dfc967f3c553158c87344a4206462c47dffab1fd1cbf6692b803015
|
|
| MD5 |
ec658d4cc8e1a339b81bc2d3214dd147
|
|
| BLAKE2b-256 |
3c56404a31e991e048209124d6e1b56e11384dde764fa554b7e74bd0bbecd40a
|
File details
Details for the file magapy-0.1.2-py3-none-any.whl.
File metadata
- Download URL: magapy-0.1.2-py3-none-any.whl
- Upload date:
- Size: 10.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b312b172d5afec522340b0d59026b62a74ffc9e842922ec92458d887dc5938c
|
|
| MD5 |
864c79fe1989d707b7ce2d5a632dfd5d
|
|
| BLAKE2b-256 |
e5166853acdfb92676dcd00f04ea54f17c5f5f1cdc086aeeecd08eb0174947f5
|