浏览代码

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.
Colin Powell 2 年之前
父节点
当前提交
27ffd35826
共有 1 个文件被更改,包括 7 次插入7 次删除
  1. 7 7
      vrobbler/apps/scrobbles/views.py

+ 7 - 7
vrobbler/apps/scrobbles/views.py

@@ -143,9 +143,10 @@ def jellyfin_websocket(request):
             video, request.user.id, jellyfin_data
             video, request.user.id, jellyfin_data
         )
         )
     if track:
     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(
         scrobble = Scrobble.create_or_update_for_track(
             track, request.user.id, jellyfin_data
             track, request.user.id, jellyfin_data
         )
         )
@@ -195,10 +196,9 @@ def mopidy_websocket(request):
 
 
     scrobble = None
     scrobble = None
     if track:
     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(
         scrobble = Scrobble.create_or_update_for_track(
             track, request.user.id, mopidy_data
             track, request.user.id, mopidy_data
         )
         )