Rules for providers that stream
Music Assistant plays music to the user’s own speakers; it is not a way to download or keep copies of it. A provider that talks to a music service follows these rules in its code. The usage policy gives the reasons, and a change that weakens one of them is not accepted.
Sign in as the user
Section titled “Sign in as the user”- Fetch audio the way an ordinary client does, with the account the user configured. Do not bypass a subscription tier or regional availability.
- Where the service protects its audio, get the key or licence the way its own client does, for that account, and decode only to play. Pass the key in
StreamDetails.decryption_key(StreamType.ENCRYPTED_HTTP). Skip an item the account has no licence for.
Be a careful client of the API
Section titled “Be a careful client of the API”- Throttle. Every request goes through a throttler set to what the service tolerates, and you report a 429 to it with the wait the service asks for: see the throttler.
- Priority. Leave the priority to the server, which sets it where a request starts; set it only for background work your provider starts itself: see priorities.
- Cache. Answer a lookup that repeats from the cache instead of asking the service again: see the cache.
- No catalogue walks. One user action or background job never sends a request per album, track or page of an artist’s discography or of a service listing. Never build what the service has no endpoint for that way: without an artist tracks endpoint, do not declare
ProviderFeature.ARTIST_TRACKS(artist top tracks,ARTIST_TOPTRACKS, is a feature of its own). Paging through the user’s own library, through the throttler, is fine. - Cap artist albums. A listing of an artist’s albums stops at
ARTIST_ALBUMS_LIMITreleases (100, inmodels/music_provider.py).
Keep the audio inside the server
Section titled “Keep the audio inside the server”- The stream address stays in
StreamDetails. Itspathis never serialized. Never put the address on a media item, in an API result or behind a route that hands it to a caller. - Keep nothing decoded. Return a stream, never audio written to disk or kept in a cache.
- Respect the service’s stream limit.
max_concurrent_streamsonMusicProviderhas a default for a streaming provider (DEFAULT_MAX_CONCURRENT_STREAMS). Where the service states how many streams one account may run at once, override it with that number.
WARNING
A provider that hammers a service puts the account of every Music Assistant user of that service at risk, not only yours.
Music Assistant is a project of the Open Home Foundation.