feat: removing dependence beteen artist.album and album.artist

This commit is contained in:
Hazel 2024-05-16 13:41:06 +02:00
parent 82df96a193
commit 41a91a6afe

View File

@ -108,8 +108,8 @@ class Song(Base):
"artwork": Artwork, "artwork": Artwork,
"main_artist_collection": Collection, "main_artist_collection": Collection,
"album_collection": Collection,
"feature_artist_collection": Collection, "feature_artist_collection": Collection,
"album_collection": Collection,
"title": lambda: None, "title": lambda: None,
"unified_title": lambda: None, "unified_title": lambda: None,
@ -376,6 +376,7 @@ class Album(Base):
def _compile(self): def _compile(self):
self.analyze_implied_album_type() self.analyze_implied_album_type()
self.update_tracksort() self.update_tracksort()
self.fix_artist_collection()
def analyze_implied_album_type(self): def analyze_implied_album_type(self):
# if the song collection has only one song, it is reasonable to assume that it is a single # 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] = existing_list.pop(0)
tracksort_map[i].tracksort = i 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 @property
def copyright(self) -> str: def copyright(self) -> str:
if self.date is None: if self.date is None:
@ -510,10 +521,6 @@ class Artist(Base):
UPWARDS_COLLECTION_STRING_ATTRIBUTES = ("label_collection",) UPWARDS_COLLECTION_STRING_ATTRIBUTES = ("label_collection",)
def __init_collections__(self): def __init_collections__(self):
self.main_album_collection.append_object_to_attribute = {
"artist_collection": self
}
self.label_collection.append_object_to_attribute = { self.label_collection.append_object_to_attribute = {
"current_artist_collection": self "current_artist_collection": self
} }