Metadata, plugin and audio analysis providers
These three provider types each subclass a base class in music_assistant/models/. As for a music provider, you pass a set of ProviderFeature values to the constructor, and the server only calls the methods of the features in it.
Metadata providers
Section titled “Metadata providers”A metadata provider fills in what the music sources leave out, such as artwork, biographies and lyrics. The metadata controller asks it when it refreshes an item: see Library, sync and metadata.
- Subclass
MetadataProvider. - Declare
ARTIST_METADATA,ALBUM_METADATA,TRACK_METADATAorPLAYLIST_METADATA, and implement the matchingget_artist_metadata(),get_album_metadata(),get_track_metadata()orget_playlist_metadata(). Each returnsMediaItemMetadata, orNonewhen you have nothing. priorityorders the providers, lower first. Setis_localfor a provider that reads local storage instead of an online service, and reportrate_limitedwhile you hold requests back.- Similar tracks and artists, artist top tracks and recommendations are optional features of their own.
There is no demo metadata provider. Learn from fanarttv (artwork from an online service) or lrclib (lyrics).
Plugin providers
Section titled “Plugin providers”A plugin adds a feature to the core. Subclass PluginProvider and pick the features:
| Feature | What you implement | Example |
|---|---|---|
AUDIO_SOURCE |
get_audio_sources() returns AudioSource items a player can play; get_stream_details() and, for a custom stream, get_audio_stream() deliver the audio |
airplay_receiver |
AI_QUERY |
get_ai_engines() and ai_query(); for images also get_image_engines() and ai_generate_image() |
openai_compatible |
TTS |
get_tts_engines() and get_tts_message(), which returns StreamDetails with a URL or a local file that stays playable |
openai_tts |
SCROBBLE |
on_media_item_played(), which gets a progress report of what plays; ScrobblerHelper in helpers/scrobbler.py does the usual now-playing and scrobble handling |
lastfm_scrobble |
- Audio sources.
get_stream_details()has no side effects, as the server also calls it to load ahead. Claim an exclusive source inon_source_selected()and release it inon_source_unselected(). The docstrings inmedia_capabilities.pyhold the streaming contract. - Engines. One plugin can offer several AI, image or speech engines, such as one per Home Assistant entity. The user picks one in the settings of the provider that uses it; your provider gets back the engine’s own
id. - Search, browse and recommendations are optional features of a plugin too.
- Stored player ids. A provider of any type that stores a player id resolves it with
mass.players.resolve_player_id()where it reads it, as the player may have been merged into another one. The players README covers legacy ids,keep_player()andPLAYER_REMOVED.
List audio_source, ai, tts or scrobble in provides of the manifest when your provider has the matching feature in every config. A plugin can also add menu actions, tools for AI assistants and a page.
Start from _demo_plugin_provider: an audio source and a scrobbler, with a menu action, an MCP tool and a page.
Audio analysis providers
Section titled “Audio analysis providers”An audio analysis provider listens to the audio itself. It reads the raw PCM of a track while it plays, or during a background scan, and derives data from it: loudness, tempo, beats and downbeats, key, energy or a fingerprint. It gets a copy of the decoded audio and never changes what is played.
The server keeps the results per item and per analysis provider in audio_analysis.db (see Where data lives). Other parts use them for volume normalization, smart crossfades, similar tracks and matching metadata.
The server has four of them, each with a page in the user documentation: Loudness Analysis, Smart Fades, Sonic Analysis and AcoustID Lookup.
Subclass AudioAnalysisProvider and implement:
_start_analysis(): set up a session; returnFalseto refuse it.process_pcm_chunk(): handle one chunk. Await all its work, as that holds the audio source back, and keep little in memory._finalize(): return theAudioAnalysisData, orNoneto skip. The base class stores it and then callspost_analysis().
Further:
- Raise
analysis_versionwhen your algorithm changes: tracks analyzed with an older version are analyzed again. media_typessays what you are offered (tracks by default),max_analysis_durationskips longer items, andhas_unloadable_modelswith_load_models()and_free_models()frees heavy models while idle.post_analysis()runs for playback and for background scans alike: it checks itself thatstreamdetails.pathis a file it may write to.- Background scans only cover local files, because of the usage policy. Leave that restriction in place.
Start from _demo_audio_analysis_provider, and learn from loudness_analysis.
Music Assistant is a project of the Open Home Foundation.