From 99da9b62bfeaae837cdc60fc2520e27ddde06965 Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Sat, 29 Mar 2025 13:45:53 -0400 Subject: [PATCH] [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. --- vrobbler/apps/music/utils.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/vrobbler/apps/music/utils.py b/vrobbler/apps/music/utils.py index 202350d..4e6f9b9 100644 --- a/vrobbler/apps/music/utils.py +++ b/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,