Skip to content

Commit

Permalink
Jellyfin: Don't fail entire sync if a single track or album have an i…
Browse files Browse the repository at this point in the history
…nvalid mbid (#1338)
  • Loading branch information
Jc2k authored Jun 10, 2024
1 parent 05bfaf5 commit c472f4c
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions music_assistant/server/providers/jellyfin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,11 +318,16 @@ async def _parse_album(self, jellyfin_album: dict[str, Any]) -> Album:
if ITEM_KEY_OVERVIEW in current_jellyfin_album:
album.metadata.description = current_jellyfin_album[ITEM_KEY_OVERVIEW]
if ITEM_KEY_MUSICBRAINZ_RELEASE_GROUP in current_jellyfin_album[ITEM_KEY_PROVIDER_IDS]:
musicbrainzid = current_jellyfin_album[ITEM_KEY_PROVIDER_IDS][
ITEM_KEY_MUSICBRAINZ_RELEASE_GROUP
]
if len(musicbrainzid.split("-")) == 5:
album.mbid = musicbrainzid
try:
album.mbid = current_jellyfin_album[ITEM_KEY_PROVIDER_IDS][
ITEM_KEY_MUSICBRAINZ_RELEASE_GROUP
]
except InvalidDataError as error:
self.logger.warning(
"Jellyfin has an invalid musicbrainz id for album %s",
album.name,
exc_info=error if self.logger.isEnabledFor(logging.DEBUG) else None,
)
if ITEM_KEY_SORT_NAME in current_jellyfin_album:
album.sort_name = current_jellyfin_album[ITEM_KEY_SORT_NAME]
if ITEM_KEY_ALBUM_ARTIST in current_jellyfin_album:
Expand Down Expand Up @@ -482,7 +487,15 @@ async def _parse_track(self, jellyfin_track: dict[str, Any]) -> Track:
) # 10000000 ticks per millisecond
track.track_number = current_jellyfin_track.get(ITEM_KEY_INDEX_NUMBER, 99)
if ITEM_KEY_MUSICBRAINZ_TRACK in current_jellyfin_track[ITEM_KEY_PROVIDER_IDS]:
track.mbid = current_jellyfin_track[ITEM_KEY_PROVIDER_IDS][ITEM_KEY_MUSICBRAINZ_TRACK]
track_mbid = current_jellyfin_track[ITEM_KEY_PROVIDER_IDS][ITEM_KEY_MUSICBRAINZ_TRACK]
try:
track.mbid = track_mbid
except InvalidDataError as error:
self.logger.warning(
"Jellyfin has an invalid musicbrainz id for track %s",
track.name,
exc_info=error if self.logger.isEnabledFor(logging.DEBUG) else None,
)
return track

async def _parse_playlist(self, jellyfin_playlist: dict[str, Any]) -> Playlist:
Expand Down

0 comments on commit c472f4c

Please sign in to comment.