From 41a91a6afeef4bc71eec6f74c1466f563fb1255f Mon Sep 17 00:00:00 2001 From: Lars Noack Date: Thu, 16 May 2024 13:41:06 +0200 Subject: [PATCH] feat: removing dependence beteen artist.album and album.artist --- music_kraken/objects/song.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/music_kraken/objects/song.py b/music_kraken/objects/song.py index 8e30a9a..48f6edd 100644 --- a/music_kraken/objects/song.py +++ b/music_kraken/objects/song.py @@ -108,8 +108,8 @@ class Song(Base): "artwork": Artwork, "main_artist_collection": Collection, - "album_collection": Collection, "feature_artist_collection": Collection, + "album_collection": Collection, "title": lambda: None, "unified_title": lambda: None, @@ -376,6 +376,7 @@ class Album(Base): def _compile(self): self.analyze_implied_album_type() self.update_tracksort() + self.fix_artist_collection() def analyze_implied_album_type(self): # if the song collection has only one song, it is reasonable to assume that it is a single @@ -417,6 +418,16 @@ class Album(Base): tracksort_map[i] = existing_list.pop(0) tracksort_map[i].tracksort = i + def fix_artist_collection(self): + """ + I add artists, that could only be feature artists to the feature artist collection. + They get automatically moved to main artist collection, if a matching artist exists in the main artist collection or is appended to it later on. + If I am not sure for any artist, I try to analyze the most common artist in the song collection of one album. + """ + + # move all artists that are in all feature_artist_collections, of every song, to the main_artist_collection + pass + @property def copyright(self) -> str: if self.date is None: @@ -510,10 +521,6 @@ class Artist(Base): UPWARDS_COLLECTION_STRING_ATTRIBUTES = ("label_collection",) def __init_collections__(self): - self.main_album_collection.append_object_to_attribute = { - "artist_collection": self - } - self.label_collection.append_object_to_attribute = { "current_artist_collection": self }