MoosicBox Library Music API
A MusicApi implementation for local library access, providing access to artists, albums, tracks, and search functionality against a local library database.
Features
- Local Library Access: Query artists, albums, and tracks from a local database
- Search: Full-text search across the library
- Favorites Management: Add/remove artists, albums, and tracks as favorites
- Profile Support: Manage multiple library databases via
LibraryMusicApiProfiles - Library Scanning: Scan local files to populate the library
- Audio Encoding: Support for multiple audio formats (AAC, FLAC, MP3, Opus)
- Actix-web Integration: Automatic profile extraction from HTTP requests (with
apifeature)
Installation
Add to your Cargo.toml:
[]
= { = "0.1.4" }
Usage
Basic Usage
use LibraryMusicApi;
use LibraryDatabase;
// Create a LibraryMusicApi from a database
let api = new;
// Or convert from a LibraryDatabase
let api: LibraryMusicApi = db.into;
Using the MusicApi Trait
The LibraryMusicApi implements the MusicApi trait from moosicbox_music_api:
use MusicApi;
// Get artists with pagination
let artists = api.artists.await?;
// Get a specific album
let album = api.album.await?;
// Search the library
let results = api.search.await?;
// Manage favorites
api.add_album.await?;
api.remove_track.await?;
// Scan the library
api.enable_scan.await?;
api.scan.await?;
Profile Management
Manage multiple library databases simultaneously:
use ;
// Add a profile
PROFILES.add;
// Retrieve a profile's API
let api = PROFILES.get;
// List all profile names
let names = PROFILES.names;
// Remove a profile
PROFILES.remove;
Cargo Features
default: Enablesall-encodersandapiapi: Actix-web integration for profile extraction from requestsall-encoders: All audio encoders (AAC, FLAC, MP3, Opus)all-os-encoders: Open-source encoders (AAC, FLAC, Opus)encoder-aac: AAC encoding supportencoder-flac: FLAC encoding supportencoder-mp3: MP3 encoding supportencoder-opus: Opus encoding supportall-formats: All audio format supportall-os-formats: Open-source audio format support (AAC, FLAC, Opus)format-aac: AAC format supportformat-flac: FLAC format supportformat-mp3: MP3 format supportformat-opus: Opus format supportsimulator: Testing simulator supportfail-on-warnings: Enables warning denial across this crate and dependencies
License
See the LICENSE file for details.