fix/clean_feature_artists #38
@ -21,5 +21,5 @@ if __name__ == "__main__":
|
||||
song_1.merge(song_2)
|
||||
|
||||
print("#" * 120)
|
||||
print("main", *song_1.main_artist_collection)
|
||||
print("main", *song_1.artist_collection)
|
||||
print("feat", *song_1.feature_artist_collection)
|
||||
|
@ -226,7 +226,7 @@ class Downloader:
|
||||
if album is not None:
|
||||
song.album_collection.append(album)
|
||||
if artist is not None:
|
||||
song.main_artist_collection.append(artist)
|
||||
song.artist_collection.append(artist)
|
||||
return Query(raw_query=query, music_object=song)
|
||||
|
||||
if album is not None:
|
||||
|
@ -239,7 +239,7 @@ class Pages:
|
||||
naming["isrc"].append(song.isrc)
|
||||
naming["album"].extend(a.title_string for a in song.album_collection)
|
||||
naming["album_type"].extend(a.album_type.value for a in song.album_collection)
|
||||
naming["artist"].extend(a.name for a in song.main_artist_collection)
|
||||
naming["artist"].extend(a.name for a in song.artist_collection)
|
||||
naming["artist"].extend(a.name for a in song.feature_artist_collection)
|
||||
for a in song.album_collection:
|
||||
naming["label"].extend([l.title_string for l in a.label_collection])
|
||||
|
@ -95,7 +95,7 @@ class Song(Base):
|
||||
target_collection: Collection[Target]
|
||||
lyrics_collection: Collection[Lyrics]
|
||||
|
||||
main_artist_collection: Collection[Artist]
|
||||
artist_collection: Collection[Artist]
|
||||
feature_artist_collection: Collection[Artist]
|
||||
album_collection: Collection[Album]
|
||||
|
||||
@ -107,7 +107,7 @@ class Song(Base):
|
||||
"lyrics_collection": Collection,
|
||||
"artwork": Artwork,
|
||||
|
||||
"main_artist_collection": Collection,
|
||||
"artist_collection": Collection,
|
||||
"feature_artist_collection": Collection,
|
||||
"album_collection": Collection,
|
||||
|
||||
@ -141,23 +141,23 @@ class Song(Base):
|
||||
|
||||
Base.__init__(**real_kwargs)
|
||||
|
||||
UPWARDS_COLLECTION_STRING_ATTRIBUTES = ("main_artist_collection", "feature_artist_collection", "album_collection")
|
||||
UPWARDS_COLLECTION_STRING_ATTRIBUTES = ("artist_collection", "feature_artist_collection", "album_collection")
|
||||
TITEL = "title"
|
||||
|
||||
def __init_collections__(self) -> None:
|
||||
self.album_collection.sync_on_append = {
|
||||
"artist_collection": self.main_artist_collection,
|
||||
"artist_collection": self.artist_collection,
|
||||
}
|
||||
|
||||
self.album_collection.append_object_to_attribute = {
|
||||
"song_collection": self,
|
||||
}
|
||||
self.main_artist_collection.extend_object_to_attribute = {
|
||||
self.artist_collection.extend_object_to_attribute = {
|
||||
"main_album_collection": self.album_collection
|
||||
}
|
||||
|
||||
self.feature_artist_collection.push_to = [self.main_artist_collection]
|
||||
self.main_artist_collection.pull_from = [self.feature_artist_collection]
|
||||
self.feature_artist_collection.push_to = [self.artist_collection]
|
||||
self.artist_collection.pull_from = [self.feature_artist_collection]
|
||||
|
||||
def _add_other_db_objects(self, object_type: Type[OuterProxy], object_list: List[OuterProxy]):
|
||||
if object_type is Song:
|
||||
@ -200,14 +200,14 @@ class Song(Base):
|
||||
|
||||
# metadata.merge_many([s.get_song_metadata() for s in self.source_collection]) album sources have no relevant metadata for id3
|
||||
metadata.merge_many([a.metadata for a in self.album_collection])
|
||||
metadata.merge_many([a.metadata for a in self.main_artist_collection])
|
||||
metadata.merge_many([a.metadata for a in self.artist_collection])
|
||||
metadata.merge_many([a.metadata for a in self.feature_artist_collection])
|
||||
metadata.merge_many([lyrics.metadata for lyrics in self.lyrics_collection])
|
||||
|
||||
return metadata
|
||||
|
||||
def get_artist_credits(self) -> str:
|
||||
main_artists = ", ".join([artist.name for artist in self.main_artist_collection])
|
||||
main_artists = ", ".join([artist.name for artist in self.artist_collection])
|
||||
feature_artists = ", ".join([artist.name for artist in self.feature_artist_collection])
|
||||
|
||||
if len(feature_artists) == 0:
|
||||
@ -218,7 +218,7 @@ class Song(Base):
|
||||
def option_string(self) -> str:
|
||||
r = OPTION_FOREGROUND.value + self.title_string + BColors.ENDC.value + OPTION_BACKGROUND.value
|
||||
r += get_collection_string(self.album_collection, " from {}", ignore_titles={self.title})
|
||||
r += get_collection_string(self.main_artist_collection, " by {}")
|
||||
r += get_collection_string(self.artist_collection, " by {}")
|
||||
r += get_collection_string(self.feature_artist_collection, " feat. {}")
|
||||
return r
|
||||
|
||||
@ -270,6 +270,7 @@ class Album(Base):
|
||||
|
||||
"source_collection": SourceCollection,
|
||||
"artist_collection": Collection,
|
||||
|
||||
"song_collection": Collection,
|
||||
"label_collection": Collection,
|
||||
}
|
||||
@ -307,7 +308,7 @@ class Album(Base):
|
||||
"album_collection": self
|
||||
}
|
||||
self.song_collection.sync_on_append = {
|
||||
"main_artist_collection": self.artist_collection
|
||||
"artist_collection": self.artist_collection
|
||||
}
|
||||
|
||||
self.artist_collection.append_object_to_attribute = {
|
||||
@ -425,7 +426,7 @@ class Album(Base):
|
||||
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
|
||||
# move all artists that are in all feature_artist_collections, of every song, to the artist_collection
|
||||
pass
|
||||
|
||||
@property
|
||||
|
@ -266,7 +266,7 @@ class EncyclopaediaMetallum(Page):
|
||||
|
||||
song_title = song.title.strip()
|
||||
album_titles = ["*"] if song.album_collection.empty else [album.title.strip() for album in song.album_collection]
|
||||
artist_titles = ["*"] if song.main_artist_collection.empty else [artist.name.strip() for artist in song.main_artist_collection]
|
||||
artist_titles = ["*"] if song.artist_collection.empty else [artist.name.strip() for artist in song.artist_collection]
|
||||
|
||||
|
||||
search_results = []
|
||||
|
@ -24,7 +24,7 @@ class Query:
|
||||
return [self.music_object.name]
|
||||
|
||||
if isinstance(self.music_object, Song):
|
||||
return [f"{artist.name} - {self.music_object}" for artist in self.music_object.main_artist_collection]
|
||||
return [f"{artist.name} - {self.music_object}" for artist in self.music_object.artist_collection]
|
||||
|
||||
if isinstance(self.music_object, Album):
|
||||
return [f"{artist.name} - {self.music_object}" for artist in self.music_object.artist_collection]
|
||||
|
@ -86,7 +86,7 @@ class TestCollection(unittest.TestCase):
|
||||
]
|
||||
)
|
||||
|
||||
self.assertTrue(artist.id == artist.main_album_collection[0].song_collection[0].main_artist_collection[0].id)
|
||||
self.assertTrue(artist.id == artist.main_album_collection[0].song_collection[0].artist_collection[0].id)
|
||||
|
||||
def test_artist_collection_sync(self):
|
||||
album_1 = Album(
|
||||
@ -111,13 +111,13 @@ class TestCollection(unittest.TestCase):
|
||||
|
||||
album_1.merge(album_2)
|
||||
|
||||
self.assertTrue(id(album_1.artist_collection) == id(album_1.artist_collection) == id(album_1.song_collection[0].main_artist_collection) == id(album_1.song_collection[0].main_artist_collection))
|
||||
self.assertTrue(id(album_1.artist_collection) == id(album_1.artist_collection) == id(album_1.song_collection[0].artist_collection) == id(album_1.song_collection[0].artist_collection))
|
||||
|
||||
def test_song_artist_relations(self):
|
||||
a = self.complicated_object()
|
||||
b = a.main_album_collection[0].song_collection[0].main_artist_collection[0]
|
||||
c = b.main_album_collection[0].song_collection[0].main_artist_collection[0]
|
||||
d = c.main_album_collection[0].song_collection[0].main_artist_collection[0]
|
||||
b = a.main_album_collection[0].song_collection[0].artist_collection[0]
|
||||
c = b.main_album_collection[0].song_collection[0].artist_collection[0]
|
||||
d = c.main_album_collection[0].song_collection[0].artist_collection[0]
|
||||
|
||||
self.assertTrue(a.id == b.id == c.id == d.id)
|
||||
self.assertTrue(a.name == b.name == c.name == d.name == "artist")
|
||||
|
Loading…
Reference in New Issue
Block a user