From d18239859e8157cd04b97e292bf09755409d0587 Mon Sep 17 00:00:00 2001 From: Eric Munson Date: Sat, 2 Nov 2024 12:14:15 -0400 Subject: [PATCH] Various fixes for the Subsonic provider (#1758) --- .../providers/opensubsonic/manifest.json | 2 +- .../providers/opensubsonic/sonic_provider.py | 27 ++++++++++--------- requirements_all.txt | 2 +- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/music_assistant/server/providers/opensubsonic/manifest.json b/music_assistant/server/providers/opensubsonic/manifest.json index 002cb5be8..fda0aa2a3 100644 --- a/music_assistant/server/providers/opensubsonic/manifest.json +++ b/music_assistant/server/providers/opensubsonic/manifest.json @@ -7,7 +7,7 @@ "@khers" ], "requirements": [ - "py-opensonic==5.1.1" + "py-opensonic==5.2.1" ], "documentation": "https://music-assistant.io/music-providers/subsonic/", "multi_instance": true diff --git a/music_assistant/server/providers/opensubsonic/sonic_provider.py b/music_assistant/server/providers/opensubsonic/sonic_provider.py index 556cc2ba3..6c9f96913 100644 --- a/music_assistant/server/providers/opensubsonic/sonic_provider.py +++ b/music_assistant/server/providers/opensubsonic/sonic_provider.py @@ -99,14 +99,12 @@ async def handle_async_init(self) -> None: try: success = await self._run_async(self._conn.ping) if not success: - msg = ( - f"Failed to connect to {self.config.get_value(CONF_BASE_URL)}, " - "check your settings." - ) - raise LoginFailed(msg) + raise CredentialError except (AuthError, CredentialError) as e: msg = ( - f"Failed to connect to {self.config.get_value(CONF_BASE_URL)}, check your settings." + "Failed to connect to " + f"{self.config.get_value(CONF_BASE_URL)}" + ", check your settings." ) raise LoginFailed(msg) from e self._enable_podcasts = self.config.get_value(CONF_ENABLE_PODCASTS) @@ -322,8 +320,9 @@ def _parse_album(self, sonic_album: SonicAlbum, sonic_info: SonicAlbumInfo = Non ) else: self.logger.info( - f"Unable to find an artist ID for album '{sonic_album.name}' with " - f"ID '{sonic_album.id}'." + "Unable to find an artist ID for album '%s' with ID '%s'.", + sonic_album.name, + sonic_album.id, ) album.artists.append( Artist( @@ -369,7 +368,7 @@ def _parse_track(self, sonic_song: SonicSong) -> Track: # We are setting disc number to 0 because the standard for what is part of # a Open Subsonic Song is not yet set and the implementations I have checked # do not contain this field. We should revisit this when the spec is finished - disc_number=0, + disc_number=sonic_song.disc_number or 0, favorite=bool(sonic_song.starred), provider_mappings={ ProviderMapping( @@ -411,13 +410,14 @@ def _parse_track(self, sonic_song: SonicSong) -> Track: # because it will not have an entry in the artists table so the best we can do it # add a 'fake' id with the proper artist name and have get_artist() check for this # id and handle it locally. + fake_id = f"{NAVI_VARIOUS_PREFIX}{sonic_song.artist}" artist = Artist( - item_id=f"{NAVI_VARIOUS_PREFIX}{sonic_song.artist}", + item_id=fake_id, provider=self.domain, name=sonic_song.artist, provider_mappings={ ProviderMapping( - item_id=UNKNOWN_ARTIST_ID, + item_id=fake_id, provider_domain=self.domain, provider_instance=self.instance_id, ) @@ -425,8 +425,9 @@ def _parse_track(self, sonic_song: SonicSong) -> Track: ) else: self.logger.info( - f"Unable to find artist ID for track '{sonic_song.title}' with " - f"ID '{sonic_song.id}'." + "Unable to find artist ID for track '%s' with ID '%s'.", + sonic_song.title, + sonic_song.id, ) artist = Artist( item_id=UNKNOWN_ARTIST_ID, diff --git a/requirements_all.txt b/requirements_all.txt index 9b57dd5fb..8e446fdae 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -27,7 +27,7 @@ orjson==3.10.10 pillow==11.0.0 pkce==1.0.3 plexapi==4.15.16 -py-opensonic==5.1.1 +py-opensonic==5.2.1 pyblu==1.0.4 PyChromecast==14.0.5 pycryptodome==3.21.0