From 27ffd358266ac124d4a6e98af30edf8e3c9772d7 Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Sun, 8 Jan 2023 23:08:36 -0500 Subject: [PATCH] Fix bug with Jellyfin mbrainz IDs being poor Turns out Jellyfin uses a really esoteric form of Musicbrainz ID for tracks. Instead of using the recording ID, it uses the specific hash for a given version of a recording. A noble effrot to be specific, but we'd much rather use Mopidy's recording ID when it's available. Thus, we'll use Jellyfin's ID if that's all we have, but if we scrobble the same track from Mopidy, overwrite the value. --- vrobbler/apps/scrobbles/views.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/vrobbler/apps/scrobbles/views.py b/vrobbler/apps/scrobbles/views.py index 308d3fe..87a9935 100644 --- a/vrobbler/apps/scrobbles/views.py +++ b/vrobbler/apps/scrobbles/views.py @@ -143,9 +143,10 @@ def jellyfin_websocket(request): video, request.user.id, jellyfin_data ) if track: - # Prefer Jellyfin track IDs to Mopidy, so just overwrite anything in there - track.musicbrainz_id = data_dict.get(KEYS["TRACK_MB_ID"], None) - track.save() + # Prefer Mopidy MD IDs to Jellyfin, so skip if we already have one + if not track.musicbrainz_id: + track.musicbrainz_id = data_dict.get(KEYS["TRACK_MB_ID"], None) + track.save() scrobble = Scrobble.create_or_update_for_track( track, request.user.id, jellyfin_data ) @@ -195,10 +196,9 @@ def mopidy_websocket(request): scrobble = None if track: - # Mopidy MB ids suck, we'd prefer jellyfin, but we'll take this if we have no other - if not track.musicbrainz_id: - track.musicbrainz_id = data_dict.get("musicbrainz_track_id") - track.save() + # Jellyfin MB ids suck, so always overwrite with Mopidy if they're offering + track.musicbrainz_id = data_dict.get("musicbrainz_track_id") + track.save() scrobble = Scrobble.create_or_update_for_track( track, request.user.id, mopidy_data )