feat: renamed main album collection to album collection
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/pr/woodpecker Pipeline was successful

This commit is contained in:
Hazel 2024-05-16 14:10:00 +02:00
parent 8ccc28daf8
commit adcf26b518
5 changed files with 28 additions and 23 deletions

View File

@ -153,7 +153,12 @@ class Song(Base):
"song_collection": self, "song_collection": self,
} }
self.artist_collection.extend_object_to_attribute = { self.artist_collection.extend_object_to_attribute = {
"main_album_collection": self.album_collection "album_collection": self.album_collection
}
self.album_collection.append_object_to_attribute = {
"artist_collection": self
} }
self.feature_artist_collection.push_to = [self.artist_collection] self.feature_artist_collection.push_to = [self.artist_collection]
@ -314,7 +319,7 @@ class Album(Base):
} }
self.artist_collection.append_object_to_attribute = { self.artist_collection.append_object_to_attribute = {
"main_album_collection": self "album_collection": self
} }
self.artist_collection.extend_object_to_attribute = { self.artist_collection.extend_object_to_attribute = {
"label_collection": self.label_collection "label_collection": self.label_collection
@ -475,7 +480,7 @@ class Artist(Base):
source_collection: SourceCollection source_collection: SourceCollection
contact_collection: Collection[Contact] contact_collection: Collection[Contact]
main_album_collection: Collection[Album] album_collection: Collection[Album]
label_collection: Collection[Label] label_collection: Collection[Label]
_default_factories = { _default_factories = {
@ -489,7 +494,7 @@ class Artist(Base):
"general_genre": lambda: "", "general_genre": lambda: "",
"source_collection": SourceCollection, "source_collection": SourceCollection,
"main_album_collection": Collection, "album_collection": Collection,
"contact_collection": Collection, "contact_collection": Collection,
"label_collection": Collection, "label_collection": Collection,
} }
@ -520,7 +525,7 @@ class Artist(Base):
Base.__init__(**real_kwargs) Base.__init__(**real_kwargs)
DOWNWARDS_COLLECTION_STRING_ATTRIBUTES = ("main_album_collection",) DOWNWARDS_COLLECTION_STRING_ATTRIBUTES = ("album_collection",)
UPWARDS_COLLECTION_STRING_ATTRIBUTES = ("label_collection",) UPWARDS_COLLECTION_STRING_ATTRIBUTES = ("label_collection",)
def __init_collections__(self): def __init_collections__(self):
@ -537,7 +542,7 @@ class Artist(Base):
return return
if object_type is Album: if object_type is Album:
self.main_album_collection.extend(object_list) self.album_collection.extend(object_list)
return return
if object_type is Label: if object_type is Label:
@ -550,7 +555,7 @@ class Artist(Base):
def update_albumsort(self): def update_albumsort(self):
""" """
This updates the albumsort attributes, of the albums in This updates the albumsort attributes, of the albums in
`self.main_album_collection`, and sorts the albums, if possible. `self.album_collection`, and sorts the albums, if possible.
It is advised to only call this function, once all the albums are It is advised to only call this function, once all the albums are
added to the artist. added to the artist.
@ -568,7 +573,7 @@ class Artist(Base):
# order albums in the previously defined section # order albums in the previously defined section
album: Album album: Album
for album in self.main_album_collection: for album in self.album_collection:
sections[type_section[album.album_type]].append(album) sections[type_section[album.album_type]].append(album)
def sort_section(_section: List[Album], last_albumsort: int) -> int: def sort_section(_section: List[Album], last_albumsort: int) -> int:
@ -599,7 +604,7 @@ class Artist(Base):
album_list.extend(sections[section_index]) album_list.extend(sections[section_index])
# replace the old collection with the new one # replace the old collection with the new one
self.main_album_collection._data = album_list self.album_collection._data = album_list
INDEX_DEPENDS_ON = ("name", "source_collection", "contact_collection") INDEX_DEPENDS_ON = ("name", "source_collection", "contact_collection")
@property @property
@ -625,8 +630,8 @@ class Artist(Base):
r += get_collection_string(self.label_collection, " under {}") r += get_collection_string(self.label_collection, " under {}")
r += OPTION_BACKGROUND.value r += OPTION_BACKGROUND.value
if len(self.main_album_collection) > 0: if len(self.album_collection) > 0:
r += f" with {len(self.main_album_collection)} albums" r += f" with {len(self.album_collection)} albums"
r += BColors.ENDC.value r += BColors.ENDC.value

View File

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

View File

@ -663,7 +663,7 @@ class EncyclopaediaMetallum(Page):
artist.notes = band_notes artist.notes = band_notes
discography: List[Album] = self._fetch_artist_discography(artist_id) discography: List[Album] = self._fetch_artist_discography(artist_id)
artist.main_album_collection.extend(discography) artist.album_collection.extend(discography)
return artist 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: if not self.fetch_options.download_all and album.album_type in self.fetch_options.album_type_blacklist:
continue continue
artist.main_album_collection.append(album) artist.album_collection.append(album)
def fetch_artist(self, source: Source, **kwargs) -> Artist: def fetch_artist(self, source: Source, **kwargs) -> Artist:
""" """

View File

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