فهرست منبع

Actually fix the VA bug

Colin Powell 2 سال پیش
والد
کامیت
1ee8fc589a
3فایلهای تغییر یافته به همراه29 افزوده شده و 23 حذف شده
  1. 5 1
      todos.org
  2. 5 7
      vrobbler/apps/music/models.py
  3. 19 15
      vrobbler/apps/music/utils.py

+ 5 - 1
todos.org

@@ -16,7 +16,11 @@ other scrobblers which may have different definitions of when a scrobble
 finishes or started.
 ** TODO Fix bug in Jellyfin scrobbles that spam more scrobbles after completion :scrobbling:videos:bug:
 ** TODO Fix bug in podcast scrobbling where a second scrobble is created after completion :scrobbling:podcasts:bug:
-** TODO Fix bug with Various Artist albums being labeled with first artist as album artist :scrobbling:bug:music:
+** DONE Fix bug with Various Artist albums being labeled with first artist as album artist :scrobbling:bug:music:
+CLOSED: [2023-03-27 Mon 20:18]
+:LOGBOOK:
+CLOCK: [2023-03-26 Sun 22:01]--[2023-03-27 Mon 01:07] =>  3:06
+:END:
 ** DONE Fix bug with weekly aggregator being blank on Sundays :aggregators:music:bug:
 CLOSED: [2023-03-26 Sun 13:52]
 ** DONE Fix KoReader scrobbling to use pages rather than time of last read :scrobbling:books:improvement:

+ 5 - 7
vrobbler/apps/music/models.py

@@ -180,13 +180,11 @@ class Album(TimeStampedModel):
         from music.utils import get_or_create_various_artists
 
         multiple_artists = self.artists.count() > 1
-        if not self.album_artist:
-            if multiple_artists:
-                self.album_artist = get_or_create_various_artists()
-            else:
-                self.album_artist = self.artists.first()
-
-            self.save(update_fields=["album_artist"])
+        if multiple_artists:
+            self.album_artist = get_or_create_various_artists()
+        else:
+            self.album_artist = self.artists.first()
+        self.save(update_fields=["album_artist"])
 
     def scrape_allmusic(self, force=False) -> None:
         if not self.allmusic_id or force:

+ 19 - 15
vrobbler/apps/music/utils.py

@@ -55,22 +55,26 @@ def get_or_create_album(
 
     if not album and name:
         mbid = mbid or album_dict["mb_id"]
-        album = Album.objects.create(name=name, musicbrainz_id=mbid)
-        album.year = album_dict["year"]
-        album.musicbrainz_releasegroup_id = album_dict["mb_group_id"]
-        album.musicbrainz_albumartist_id = artist.musicbrainz_id
-        album.save(
-            update_fields=[
-                "musicbrainz_id",
-                "year",
-                "musicbrainz_releasegroup_id",
-                "musicbrainz_albumartist_id",
-            ]
+        album, album_created = Album.objects.get_or_create(
+            name=name, musicbrainz_id=mbid
         )
-        album.artists.add(artist)
-        album.fetch_artwork()
-        album.fix_album_artist()
-        album.scrape_allmusic()
+        if album_created:
+            album.year = album_dict["year"]
+            album.musicbrainz_releasegroup_id = album_dict["mb_group_id"]
+            album.musicbrainz_albumartist_id = artist.musicbrainz_id
+            album.save(
+                update_fields=[
+                    "musicbrainz_id",
+                    "year",
+                    "musicbrainz_releasegroup_id",
+                    "musicbrainz_albumartist_id",
+                ]
+            )
+            album.artists.add(artist)
+            album.fetch_artwork()
+            album.scrape_allmusic()
+    album.fix_album_artist()
+
     if not album:
         logger.warn(f"No album found for {name} and {mbid}")