from collections.abc import AsyncGenerator, Sequence
from typing import TYPE_CHECKING
-from music_assistant_models.enums import (
- ContentType,
- MediaType,
- ProviderFeature,
- StreamType,
-)
+from music_assistant_models.enums import ContentType, MediaType, ProviderFeature, StreamType
from music_assistant_models.media_items import (
Album,
Artist,
from music_assistant.models.music_provider import MusicProvider
if TYPE_CHECKING:
- from music_assistant_models.config_entries import (
- ConfigEntry,
- ConfigValueType,
- ProviderConfig,
- )
+ from music_assistant_models.config_entries import ConfigEntry, ConfigValueType, ProviderConfig
from music_assistant_models.provider import ProviderManifest
- from music_assistant import MusicAssistant
+ from music_assistant.mass import MusicAssistant
from music_assistant.models import ProviderInstanceType
# you should return a tuple of provider-level features
# here that your player provider supports or an empty tuple if none.
# for example 'ProviderFeature.SYNC_PLAYERS' if you can sync players.
- return (
+ return {
ProviderFeature.BROWSE,
ProviderFeature.SEARCH,
ProviderFeature.RECOMMENDATIONS,
ProviderFeature.LIBRARY_PLAYLISTS_EDIT,
ProviderFeature.SIMILAR_TRACKS,
# see the ProviderFeature enum for all available features
- )
+ }
async def loaded_in_mass(self) -> None:
"""Call after the provider has been loaded."""
# For streaming providers return True here but for local file based providers return False.
return True
- async def search(
+ async def search( # type: ignore[empty-body]
self,
search_query: str,
media_types: list[MediaType],
# It allows retrieving the library/favorite albums from your provider.
# Warning: Async generator:
# You should yield Album objects for each album in the library.
- yield # type: ignore
+ yield # type: ignore[misc]
async def get_library_tracks(self) -> AsyncGenerator[Track, None]:
"""Retrieve library tracks from the provider."""
# It allows retrieving the library/favorite tracks from your provider.
# Warning: Async generator:
# You should yield Track objects for each track in the library.
- yield # type: ignore
+ yield # type: ignore[misc]
async def get_library_playlists(self) -> AsyncGenerator[Playlist, None]:
"""Retrieve library/subscribed playlists from the provider."""
# It allows retrieving the library/favorite playlists from your provider.
# Warning: Async generator:
# You should yield Playlist objects for each playlist in the library.
- yield # type: ignore
+ yield # type: ignore[misc]
async def get_library_radios(self) -> AsyncGenerator[Radio, None]:
"""Retrieve library/subscribed radio stations from the provider."""
# It allows retrieving the library/favorite radio stations from your provider.
# Warning: Async generator:
# You should yield Radio objects for each radio station in the library.
- yield
+ yield # type: ignore[misc]
- async def get_artist(self, prov_artist_id: str) -> Artist:
+ async def get_artist(self, prov_artist_id: str) -> Artist: # type: ignore[empty-body]
"""Get full artist details by id."""
# Get full details of a single Artist.
# Mandatory only if you reported LIBRARY_ARTISTS in the supported_features.
- async def get_artist_albums(self, prov_artist_id: str) -> list[Album]:
+ async def get_artist_albums(self, prov_artist_id: str) -> list[Album]: # type: ignore[empty-body]
"""Get a list of all albums for the given artist."""
# Get a list of all albums for the given artist.
# Mandatory only if you reported ARTIST_ALBUMS in the supported_features.
- async def get_artist_toptracks(self, prov_artist_id: str) -> list[Track]:
+ async def get_artist_toptracks(self, prov_artist_id: str) -> list[Track]: # type: ignore[empty-body]
"""Get a list of most popular tracks for the given artist."""
# Get a list of most popular tracks for the given artist.
# Mandatory only if you reported ARTIST_TOPTRACKS in the supported_features.
# Note that (local) file based providers will simply return all artist tracks here.
- async def get_album(self, prov_album_id: str) -> Album: # type: ignore[return]
+ async def get_album(self, prov_album_id: str) -> Album: # type: ignore[empty-body]
"""Get full album details by id."""
# Get full details of a single Album.
# Mandatory only if you reported LIBRARY_ALBUMS in the supported_features.
- async def get_track(self, prov_track_id: str) -> Track: # type: ignore[return]
+ async def get_track(self, prov_track_id: str) -> Track: # type: ignore[empty-body]
"""Get full track details by id."""
# Get full details of a single Track.
# Mandatory only if you reported LIBRARY_TRACKS in the supported_features.
- async def get_playlist(self, prov_playlist_id: str) -> Playlist: # type: ignore[return]
+ async def get_playlist(self, prov_playlist_id: str) -> Playlist: # type: ignore[empty-body]
"""Get full playlist details by id."""
# Get full details of a single Playlist.
# Mandatory only if you reported LIBRARY_PLAYLISTS in the supported
- async def get_radio(self, prov_radio_id: str) -> Radio: # type: ignore[return]
+ async def get_radio(self, prov_radio_id: str) -> Radio: # type: ignore[empty-body]
"""Get full radio details by id."""
# Get full details of a single Radio station.
# Mandatory only if you reported LIBRARY_RADIOS in the supported_features.
- async def get_album_tracks(
+ async def get_album_tracks( # type: ignore[empty-body]
self,
- prov_album_id: str, # type: ignore[return]
+ prov_album_id: str,
) -> list[Track]:
"""Get album tracks for given album id."""
# Get all tracks for a given album.
# Mandatory only if you reported ARTIST_ALBUMS in the supported_features.
- async def get_playlist_tracks(
+ async def get_playlist_tracks( # type: ignore[empty-body]
self,
prov_playlist_id: str,
page: int = 0,
# Remove track(s) from a playlist.
# This is only called if the provider supports the EDPLAYLIST_TRACKS_EDITIT feature.
- async def create_playlist(self, name: str) -> Playlist: # type: ignore[return]
+ async def create_playlist(self, name: str) -> Playlist: # type: ignore[empty-body]
"""Create a new playlist on provider with given name."""
# Create a new playlist on the provider.
# This is only called if the provider supports the PLAYLIST_CREATE feature.
- async def get_similar_tracks( # type: ignore[return]
+ async def get_similar_tracks( # type: ignore[empty-body]
self, prov_track_id: str, limit: int = 25
) -> list[Track]:
"""Retrieve a dynamic list of similar tracks based on the provided track."""
# but the above should be the mandatory fields to set.
)
- async def get_audio_stream( # type: ignore[return]
+ async def get_audio_stream(
self, streamdetails: StreamDetails, seek_position: int = 0
) -> AsyncGenerator[bytes, None]:
"""
# for the given streamdetails. You can use this to provide a custom
# stream generator for the audio stream. This is only called when the
# stream_type is set to CUSTOM in the get_stream_details method.
- yield # type: ignore
+ yield # type: ignore[misc]
async def on_streamed(
self,