/
/
/
1"""
2Protocol definitions for provider dependencies.
3
4Allows typing of external provider references without importing concrete classes.
5"""
6
7from __future__ import annotations
8
9from collections.abc import AsyncGenerator
10from typing import TYPE_CHECKING, Any, Protocol, runtime_checkable
11
12if TYPE_CHECKING:
13 from contextlib import AbstractAsyncContextManager
14
15 from music_assistant_models.enums import MediaType
16 from music_assistant_models.streamdetails import StreamDetails
17
18
19@runtime_checkable
20class YandexMusicProviderLike(Protocol):
21 """
22 Structural interface for the yandex_music MusicProvider.
23
24 Only the subset of methods/properties used by the Ynison plugin.
25 """
26
27 @property
28 def instance_id(self) -> str:
29 """Return the exact linked provider instance ID."""
30 ...
31
32 @property
33 def available(self) -> bool:
34 """Return whether the linked provider instance is available."""
35 ...
36
37 async def get_stream_details(self, item_id: str, media_type: MediaType) -> StreamDetails:
38 """Resolve stream details for a track."""
39 ...
40
41 def get_audio_stream(self, stream_details: StreamDetails) -> AsyncGenerator[bytes]:
42 """Return async generator of raw audio bytes."""
43 ...
44
45 def acquire_stream_slot(self, wait_timeout: float | None) -> AbstractAsyncContextManager[None]:
46 """Acquire one upstream source-stream slot."""
47 ...
48
49 async def get_rotor_station_tracks(
50 self, station_id: str, queue: str | int | None = None
51 ) -> tuple[list[Any], str | None]:
52 """Fetch tracks from a rotor station for radio queue replenishment."""
53 ...
54