/
/
/
1"""
2Apple Music musicprovider support for MusicAssistant.
3
4TODO MUSIC_APP_TOKEN expires after 6 months so should have a distribution mechanism outside
5 compulsory application updates. It is only a semi-private key in JWT format so could be
6 refreshed daily by a GitHub action and downloaded by the provider each initialise.
7TODO Widevine keys can be obtained dynamically from Apple Music API rather than copied into Docker
8 build. This is undocumented but @maxlyth has a working example.
9TODO MUSIC_USER_TOKEN must be refreshed (~min 180 days) and needs mechanism to prompt user to
10 re-authenticate in browser.
11TODO Current provider ignores private tracks that are not available in the storefront catalog as
12 streamable url is derived from the catalog id. It is undocumented but @maxlyth has a working
13 example to get a streamable url from the library id.
14"""
15
16from __future__ import annotations
17
18from typing import TYPE_CHECKING
19
20from .provider import AppleMusicProvider
21
22__all__ = ["AppleMusicProvider", "setup"]
23
24if TYPE_CHECKING:
25 from music_assistant_models.config_entries import ProviderConfig
26 from music_assistant_models.provider import ProviderManifest
27
28 from music_assistant import MusicAssistant
29 from music_assistant.models import ProviderInstanceType
30
31
32async def setup(
33 mass: MusicAssistant, manifest: ProviderManifest, config: ProviderConfig
34) -> ProviderInstanceType:
35 """Initialize provider(instance) with given configuration."""
36 return AppleMusicProvider(mass, manifest, config)
37