feat: tried fixing the collections
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
from collections import defaultdict
|
||||
from dataclasses import dataclass
|
||||
from enum import Enum
|
||||
from typing import List, Optional, Type, Union
|
||||
from typing import List, Optional, Type, Union, Generator
|
||||
from urllib.parse import urlparse
|
||||
|
||||
import pycountry
|
||||
@@ -1056,7 +1056,7 @@ class Musify(Page):
|
||||
date=date
|
||||
)
|
||||
|
||||
def _get_discography(self, url: MusifyUrl, artist_name: str = None, stop_at_level: int = 1) -> List[Album]:
|
||||
def _get_discography(self, url: MusifyUrl, artist_name: str = None, stop_at_level: int = 1) -> Generator[Album, None, None]:
|
||||
"""
|
||||
POST https://musify.club/artist/filteralbums
|
||||
ArtistID: 280348
|
||||
@@ -1077,18 +1077,8 @@ class Musify(Page):
|
||||
return []
|
||||
soup: BeautifulSoup = BeautifulSoup(r.content, features="html.parser")
|
||||
|
||||
discography: List[Album] = []
|
||||
for card_soup in soup.find_all("div", {"class": "card"}):
|
||||
new_album: Album = self._parse_album_card(card_soup, artist_name)
|
||||
album_source: Source
|
||||
|
||||
if stop_at_level > 1:
|
||||
for album_source in new_album.source_collection.get_sources_from_page(self.SOURCE_TYPE):
|
||||
new_album.merge(self.fetch_album(album_source, stop_at_level=stop_at_level-1))
|
||||
|
||||
discography.append(new_album)
|
||||
|
||||
return discography
|
||||
yield self._parse_album_card(card_soup, artist_name)
|
||||
|
||||
def fetch_artist(self, source: Source, stop_at_level: int = 1) -> Artist:
|
||||
"""
|
||||
@@ -1110,8 +1100,7 @@ class Musify(Page):
|
||||
|
||||
artist = self._get_artist_attributes(url)
|
||||
|
||||
discography: List[Album] = self._get_discography(url, artist.name)
|
||||
artist.main_album_collection.extend(discography)
|
||||
artist.main_album_collection.extend(self._get_discography(url, artist.name))
|
||||
|
||||
return artist
|
||||
|
||||
|
||||
Reference in New Issue
Block a user