/
/
/
1"""YouSee Musik musicprovider support for MusicAssistant."""
2
3from __future__ import annotations
4
5from typing import TYPE_CHECKING
6
7from music_assistant_models.config_entries import ConfigEntry, ConfigValueOption, ConfigValueType
8from music_assistant_models.enums import (
9 ConfigEntryType,
10 ProviderFeature,
11)
12
13from music_assistant.constants import (
14 CONF_PASSWORD,
15 CONF_USERNAME,
16)
17from music_assistant.providers.yousee.constants import CONF_QUALITY
18from music_assistant.providers.yousee.provider import YouSeeMusikProvider
19
20if TYPE_CHECKING:
21 from music_assistant_models.config_entries import ProviderConfig
22 from music_assistant_models.provider import ProviderManifest
23
24 from music_assistant.mass import MusicAssistant
25 from music_assistant.models import ProviderInstanceType
26
27
28SUPPORTED_FEATURES = {
29 ProviderFeature.BROWSE,
30 ProviderFeature.SEARCH,
31 ProviderFeature.RECOMMENDATIONS,
32 ProviderFeature.LIBRARY_ARTISTS,
33 ProviderFeature.LIBRARY_ALBUMS,
34 ProviderFeature.LIBRARY_TRACKS,
35 ProviderFeature.LIBRARY_PLAYLISTS,
36 ProviderFeature.ARTIST_ALBUMS,
37 ProviderFeature.ARTIST_TOPTRACKS,
38 ProviderFeature.LIBRARY_ARTISTS_EDIT,
39 ProviderFeature.LIBRARY_ALBUMS_EDIT,
40 ProviderFeature.LIBRARY_TRACKS_EDIT,
41 ProviderFeature.LIBRARY_PLAYLISTS_EDIT,
42 ProviderFeature.PLAYLIST_TRACKS_EDIT,
43 ProviderFeature.PLAYLIST_CREATE,
44 ProviderFeature.SIMILAR_TRACKS,
45 ProviderFeature.LYRICS,
46}
47
48
49async def setup(
50 mass: MusicAssistant, manifest: ProviderManifest, config: ProviderConfig
51) -> ProviderInstanceType:
52 """Initialize provider(instance) with given configuration."""
53 # setup is called when the user wants to setup a new provider instance.
54 # you are free to do any preflight checks here and but you must return
55 # an instance of the provider.
56 return YouSeeMusikProvider(mass, manifest, config, SUPPORTED_FEATURES)
57
58
59async def get_config_entries(
60 mass: MusicAssistant,
61 instance_id: str | None = None,
62 action: str | None = None,
63 values: dict[str, ConfigValueType] | None = None,
64) -> tuple[ConfigEntry, ...]:
65 """
66 Return Config entries to setup this provider.
67
68 instance_id: id of an existing provider instance (None if new instance setup).
69 action: [optional] action key called from config entries UI.
70 values: the (intermediate) raw values for config entries sent with the action.
71 """
72 # ruff: noqa: ARG001
73 return (
74 ConfigEntry(
75 key=CONF_USERNAME,
76 type=ConfigEntryType.STRING,
77 label="Username",
78 required=True,
79 ),
80 ConfigEntry(
81 key=CONF_PASSWORD,
82 type=ConfigEntryType.SECURE_STRING,
83 label="Password",
84 required=True,
85 ),
86 ConfigEntry(
87 key=CONF_QUALITY,
88 type=ConfigEntryType.INTEGER,
89 label="Stream Quality",
90 description="The streaming quality to use for playback",
91 default_value=320,
92 options=[
93 ConfigValueOption('"High" - MP4 320kbps', 320),
94 ConfigValueOption('"Normal" - MP4 192kbps', 192),
95 ],
96 ),
97 )
98