Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Radio mode for Subsonic provider #1784

Merged
merged 4 commits into from
Nov 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions music_assistant/providers/opensubsonic/sonic_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,9 +630,16 @@ async def get_artist_toptracks(self, prov_artist_id: str) -> list[Track]:

async def get_similar_tracks(self, prov_track_id: str, limit: int = 25) -> list[Track]:
"""Get tracks similar to selected track."""
songs: list[SonicSong] = await self._run_async(
self._conn.getSimilarSongs2, id=prov_track_id, count=limit
)
try:
songs: list[SonicSong] = await self._run_async(
self._conn.getSimilarSongs, iid=prov_track_id, count=limit
)
except DataNotFoundError as e:
# Subsonic returns an error here instead of an empty list, I don't think this
# should be an exception but there we are. Return an empty list because this
# exception means we didn't find anything similar.
self.logger.info(e)
return []
return [self._parse_track(entry) for entry in songs]

async def create_playlist(self, name: str) -> Playlist:
Expand All @@ -649,9 +656,9 @@ async def add_playlist_tracks(self, prov_playlist_id: str, prov_track_ids: list[
await self._run_async(
self._conn.updatePlaylist, lid=prov_playlist_id, songIdsToAdd=prov_track_ids
)
except SonicError:
except SonicError as ex:
msg = f"Failed to add songs to {prov_playlist_id}, check your permissions."
raise ProviderPermissionDenied(msg)
raise ProviderPermissionDenied(msg) from ex

async def remove_playlist_tracks(
self, prov_playlist_id: str, positions_to_remove: tuple[int, ...]
Expand All @@ -664,9 +671,9 @@ async def remove_playlist_tracks(
lid=prov_playlist_id,
songIndexesToRemove=idx_to_remove,
)
except SonicError:
except SonicError as ex:
msg = f"Failed to remove songs from {prov_playlist_id}, check your permissions."
raise ProviderPermissionDenied(msg)
raise ProviderPermissionDenied(msg) from ex

async def get_stream_details(self, item_id: str) -> StreamDetails:
"""Get the details needed to process a specified track."""
Expand Down