Browse Source

[music] Fixes bug where lastfm created new tracks

The issue here was that if we couldn't find a track from a musicbrainz
ID (which was almost never), we would fall back to just creating a new
track with a blank album. So we'd spam the track table with identical
tracks just no albums.

Now we do a quick check for the track where the title and artist match
and use that if it's found. This will result in some tracks being
associated with the wrong album, but I think that's better than the
current behavior.
Colin Powell 1 month ago
parent
commit
99da9b62bf
1 changed files with 3 additions and 0 deletions
  1. 3 0
      vrobbler/apps/music/utils.py

+ 3 - 0
vrobbler/apps/music/utils.py

@@ -140,6 +140,9 @@ def get_or_create_track(post_data: dict, post_keys: dict) -> Track:
     if track_mb_id:
         track = Track.objects.filter(musicbrainz_id=track_mb_id).first()
 
+    if not track and track_title:
+        track = Track.objects.filter(title=track_title, artist=artist).first()
+
     if not track:
         track = Track.objects.create(
             title=track_title,