Skip to content

Commit

Permalink
Various fixes for the Subsonic provider (#1758)
Browse files Browse the repository at this point in the history
  • Loading branch information
khers authored Nov 2, 2024
1 parent d94e62d commit d182398
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 14 additions & 13 deletions music_assistant/server/providers/opensubsonic/sonic_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -411,22 +410,24 @@ 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,
)
},
)
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,
Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d182398

Please sign in to comment.