Compare commits

..

No commits in common. "adcf26b51820094e33b599ced59cf047afab25a1" and "2b3f4d82d9426c8cab119c629835307edcd0813b" have entirely different histories.

5 changed files with 26 additions and 33 deletions

View File

@ -107,9 +107,9 @@ class Song(Base):
"lyrics_collection": Collection,
"artwork": Artwork,
"album_collection": Collection,
"artist_collection": Collection,
"feature_artist_collection": Collection,
"album_collection": Collection,
"title": lambda: None,
"unified_title": lambda: None,
@ -153,12 +153,7 @@ class Song(Base):
"song_collection": self,
}
self.artist_collection.extend_object_to_attribute = {
"album_collection": self.album_collection
}
self.album_collection.append_object_to_attribute = {
"artist_collection": self
"main_album_collection": self.album_collection
}
self.feature_artist_collection.push_to = [self.artist_collection]
@ -257,9 +252,8 @@ class Album(Base):
source_collection: SourceCollection
song_collection: Collection[Song]
artist_collection: Collection[Artist]
feature_artist_collection: Collection[Artist]
song_collection: Collection[Song]
label_collection: Collection[Label]
_default_factories = {
@ -275,10 +269,9 @@ class Album(Base):
"notes": FormattedText,
"source_collection": SourceCollection,
"artist_collection": Collection,
"song_collection": Collection,
"artist_collection": Collection,
"feature_artist_collection": Collection,
"label_collection": Collection,
}
@ -319,7 +312,7 @@ class Album(Base):
}
self.artist_collection.append_object_to_attribute = {
"album_collection": self
"main_album_collection": self
}
self.artist_collection.extend_object_to_attribute = {
"label_collection": self.label_collection
@ -480,7 +473,7 @@ class Artist(Base):
source_collection: SourceCollection
contact_collection: Collection[Contact]
album_collection: Collection[Album]
main_album_collection: Collection[Album]
label_collection: Collection[Label]
_default_factories = {
@ -494,7 +487,7 @@ class Artist(Base):
"general_genre": lambda: "",
"source_collection": SourceCollection,
"album_collection": Collection,
"main_album_collection": Collection,
"contact_collection": Collection,
"label_collection": Collection,
}
@ -525,7 +518,7 @@ class Artist(Base):
Base.__init__(**real_kwargs)
DOWNWARDS_COLLECTION_STRING_ATTRIBUTES = ("album_collection",)
DOWNWARDS_COLLECTION_STRING_ATTRIBUTES = ("main_album_collection",)
UPWARDS_COLLECTION_STRING_ATTRIBUTES = ("label_collection",)
def __init_collections__(self):
@ -542,7 +535,7 @@ class Artist(Base):
return
if object_type is Album:
self.album_collection.extend(object_list)
self.main_album_collection.extend(object_list)
return
if object_type is Label:
@ -555,7 +548,7 @@ class Artist(Base):
def update_albumsort(self):
"""
This updates the albumsort attributes, of the albums in
`self.album_collection`, and sorts the albums, if possible.
`self.main_album_collection`, and sorts the albums, if possible.
It is advised to only call this function, once all the albums are
added to the artist.
@ -573,7 +566,7 @@ class Artist(Base):
# order albums in the previously defined section
album: Album
for album in self.album_collection:
for album in self.main_album_collection:
sections[type_section[album.album_type]].append(album)
def sort_section(_section: List[Album], last_albumsort: int) -> int:
@ -604,7 +597,7 @@ class Artist(Base):
album_list.extend(sections[section_index])
# replace the old collection with the new one
self.album_collection._data = album_list
self.main_album_collection._data = album_list
INDEX_DEPENDS_ON = ("name", "source_collection", "contact_collection")
@property
@ -630,8 +623,8 @@ class Artist(Base):
r += get_collection_string(self.label_collection, " under {}")
r += OPTION_BACKGROUND.value
if len(self.album_collection) > 0:
r += f" with {len(self.album_collection)} albums"
if len(self.main_album_collection) > 0:
r += f" with {len(self.main_album_collection)} albums"
r += BColors.ENDC.value

View File

@ -237,7 +237,7 @@ class Bandcamp(Page):
html_music_grid = soup.find("ol", {"id": "music-grid"})
if html_music_grid is not None:
for subsoup in html_music_grid.find_all("li"):
artist.album_collection.append(self._parse_album(soup=subsoup, initial_source=source))
artist.main_album_collection.append(self._parse_album(soup=subsoup, initial_source=source))
for i, data_blob_soup in enumerate(soup.find_all("div", {"id": ["pagedata", "collectors-data"]})):
data_blob = data_blob_soup["data-blob"]
@ -246,7 +246,7 @@ class Bandcamp(Page):
dump_to_file(f"bandcamp_artist_data_blob_{i}.json", data_blob, is_json=True, exit_after_dump=False)
if data_blob is not None:
artist.album_collection.extend(
artist.main_album_collection.extend(
self._parse_artist_data_blob(json.loads(data_blob), source.url)
)

View File

@ -663,7 +663,7 @@ class EncyclopaediaMetallum(Page):
artist.notes = band_notes
discography: List[Album] = self._fetch_artist_discography(artist_id)
artist.album_collection.extend(discography)
artist.main_album_collection.extend(discography)
return artist

View File

@ -1054,7 +1054,7 @@ class Musify(Page):
if not self.fetch_options.download_all and album.album_type in self.fetch_options.album_type_blacklist:
continue
artist.album_collection.append(album)
artist.main_album_collection.append(album)
def fetch_artist(self, source: Source, **kwargs) -> Artist:
"""

View File

@ -37,7 +37,7 @@ class TestCollection(unittest.TestCase):
is the same object
"""
a = self.complicated_object().album_collection[0]
a = self.complicated_object().main_album_collection[0]
b = a.song_collection[0].album_collection[0]
c = a.song_collection[1].album_collection[0]
d = b.song_collection[0].album_collection[0]
@ -62,9 +62,9 @@ class TestCollection(unittest.TestCase):
"""
a = self.complicated_object()
b = a.album_collection[0].artist_collection[0]
c = b.album_collection[0].artist_collection[0]
d = c.album_collection[0].artist_collection[0]
b = a.main_album_collection[0].artist_collection[0]
c = b.main_album_collection[0].artist_collection[0]
d = c.main_album_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")
@ -86,7 +86,7 @@ class TestCollection(unittest.TestCase):
]
)
self.assertTrue(artist.id == artist.album_collection[0].song_collection[0].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(
@ -115,9 +115,9 @@ class TestCollection(unittest.TestCase):
def test_song_artist_relations(self):
a = self.complicated_object()
b = a.album_collection[0].song_collection[0].artist_collection[0]
c = b.album_collection[0].song_collection[0].artist_collection[0]
d = c.album_collection[0].song_collection[0].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")