Compare commits
2 Commits
82df96a193
...
2b3f4d82d9
Author | SHA1 | Date | |
---|---|---|---|
2b3f4d82d9 | |||
41a91a6afe |
@ -21,5 +21,5 @@ if __name__ == "__main__":
|
|||||||
song_1.merge(song_2)
|
song_1.merge(song_2)
|
||||||
|
|
||||||
print("#" * 120)
|
print("#" * 120)
|
||||||
print("main", *song_1.main_artist_collection)
|
print("main", *song_1.artist_collection)
|
||||||
print("feat", *song_1.feature_artist_collection)
|
print("feat", *song_1.feature_artist_collection)
|
||||||
|
@ -226,7 +226,7 @@ class Downloader:
|
|||||||
if album is not None:
|
if album is not None:
|
||||||
song.album_collection.append(album)
|
song.album_collection.append(album)
|
||||||
if artist is not None:
|
if artist is not None:
|
||||||
song.main_artist_collection.append(artist)
|
song.artist_collection.append(artist)
|
||||||
return Query(raw_query=query, music_object=song)
|
return Query(raw_query=query, music_object=song)
|
||||||
|
|
||||||
if album is not None:
|
if album is not None:
|
||||||
|
@ -239,7 +239,7 @@ class Pages:
|
|||||||
naming["isrc"].append(song.isrc)
|
naming["isrc"].append(song.isrc)
|
||||||
naming["album"].extend(a.title_string for a in song.album_collection)
|
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["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)
|
naming["artist"].extend(a.name for a in song.feature_artist_collection)
|
||||||
for a in song.album_collection:
|
for a in song.album_collection:
|
||||||
naming["label"].extend([l.title_string for l in a.label_collection])
|
naming["label"].extend([l.title_string for l in a.label_collection])
|
||||||
|
@ -95,7 +95,7 @@ class Song(Base):
|
|||||||
target_collection: Collection[Target]
|
target_collection: Collection[Target]
|
||||||
lyrics_collection: Collection[Lyrics]
|
lyrics_collection: Collection[Lyrics]
|
||||||
|
|
||||||
main_artist_collection: Collection[Artist]
|
artist_collection: Collection[Artist]
|
||||||
feature_artist_collection: Collection[Artist]
|
feature_artist_collection: Collection[Artist]
|
||||||
album_collection: Collection[Album]
|
album_collection: Collection[Album]
|
||||||
|
|
||||||
@ -107,9 +107,9 @@ class Song(Base):
|
|||||||
"lyrics_collection": Collection,
|
"lyrics_collection": Collection,
|
||||||
"artwork": Artwork,
|
"artwork": Artwork,
|
||||||
|
|
||||||
"main_artist_collection": Collection,
|
"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,
|
||||||
@ -141,23 +141,23 @@ class Song(Base):
|
|||||||
|
|
||||||
Base.__init__(**real_kwargs)
|
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"
|
TITEL = "title"
|
||||||
|
|
||||||
def __init_collections__(self) -> None:
|
def __init_collections__(self) -> None:
|
||||||
self.album_collection.sync_on_append = {
|
self.album_collection.sync_on_append = {
|
||||||
"artist_collection": self.main_artist_collection,
|
"artist_collection": self.artist_collection,
|
||||||
}
|
}
|
||||||
|
|
||||||
self.album_collection.append_object_to_attribute = {
|
self.album_collection.append_object_to_attribute = {
|
||||||
"song_collection": self,
|
"song_collection": self,
|
||||||
}
|
}
|
||||||
self.main_artist_collection.extend_object_to_attribute = {
|
self.artist_collection.extend_object_to_attribute = {
|
||||||
"main_album_collection": self.album_collection
|
"main_album_collection": self.album_collection
|
||||||
}
|
}
|
||||||
|
|
||||||
self.feature_artist_collection.push_to = [self.main_artist_collection]
|
self.feature_artist_collection.push_to = [self.artist_collection]
|
||||||
self.main_artist_collection.pull_from = [self.feature_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]):
|
def _add_other_db_objects(self, object_type: Type[OuterProxy], object_list: List[OuterProxy]):
|
||||||
if object_type is Song:
|
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([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.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([a.metadata for a in self.feature_artist_collection])
|
||||||
metadata.merge_many([lyrics.metadata for lyrics in self.lyrics_collection])
|
metadata.merge_many([lyrics.metadata for lyrics in self.lyrics_collection])
|
||||||
|
|
||||||
return metadata
|
return metadata
|
||||||
|
|
||||||
def get_artist_credits(self) -> str:
|
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])
|
feature_artists = ", ".join([artist.name for artist in self.feature_artist_collection])
|
||||||
|
|
||||||
if len(feature_artists) == 0:
|
if len(feature_artists) == 0:
|
||||||
@ -218,7 +218,7 @@ class Song(Base):
|
|||||||
def option_string(self) -> str:
|
def option_string(self) -> str:
|
||||||
r = OPTION_FOREGROUND.value + self.title_string + BColors.ENDC.value + OPTION_BACKGROUND.value
|
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.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. {}")
|
r += get_collection_string(self.feature_artist_collection, " feat. {}")
|
||||||
return r
|
return r
|
||||||
|
|
||||||
@ -270,6 +270,7 @@ class Album(Base):
|
|||||||
|
|
||||||
"source_collection": SourceCollection,
|
"source_collection": SourceCollection,
|
||||||
"artist_collection": Collection,
|
"artist_collection": Collection,
|
||||||
|
|
||||||
"song_collection": Collection,
|
"song_collection": Collection,
|
||||||
"label_collection": Collection,
|
"label_collection": Collection,
|
||||||
}
|
}
|
||||||
@ -307,7 +308,7 @@ class Album(Base):
|
|||||||
"album_collection": self
|
"album_collection": self
|
||||||
}
|
}
|
||||||
self.song_collection.sync_on_append = {
|
self.song_collection.sync_on_append = {
|
||||||
"main_artist_collection": self.artist_collection
|
"artist_collection": self.artist_collection
|
||||||
}
|
}
|
||||||
|
|
||||||
self.artist_collection.append_object_to_attribute = {
|
self.artist_collection.append_object_to_attribute = {
|
||||||
@ -376,6 +377,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 +419,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 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 +522,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
|
||||||
}
|
}
|
||||||
|
@ -266,7 +266,7 @@ class EncyclopaediaMetallum(Page):
|
|||||||
|
|
||||||
song_title = song.title.strip()
|
song_title = song.title.strip()
|
||||||
album_titles = ["*"] if song.album_collection.empty else [album.title.strip() for album in song.album_collection]
|
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 = []
|
search_results = []
|
||||||
|
@ -24,7 +24,7 @@ class Query:
|
|||||||
return [self.music_object.name]
|
return [self.music_object.name]
|
||||||
|
|
||||||
if isinstance(self.music_object, Song):
|
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):
|
if isinstance(self.music_object, Album):
|
||||||
return [f"{artist.name} - {self.music_object}" for artist in self.music_object.artist_collection]
|
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):
|
def test_artist_collection_sync(self):
|
||||||
album_1 = Album(
|
album_1 = Album(
|
||||||
@ -111,13 +111,13 @@ class TestCollection(unittest.TestCase):
|
|||||||
|
|
||||||
album_1.merge(album_2)
|
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):
|
def test_song_artist_relations(self):
|
||||||
a = self.complicated_object()
|
a = self.complicated_object()
|
||||||
b = a.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].main_artist_collection[0]
|
c = b.main_album_collection[0].song_collection[0].artist_collection[0]
|
||||||
d = c.main_album_collection[0].song_collection[0].main_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.id == b.id == c.id == d.id)
|
||||||
self.assertTrue(a.name == b.name == c.name == d.name == "artist")
|
self.assertTrue(a.name == b.name == c.name == d.name == "artist")
|
||||||
|
Loading…
Reference in New Issue
Block a user