Artwork gallery Musify
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
465af49057
commit
5d26fdbf94
@ -477,6 +477,8 @@ class Artist(Base):
|
||||
general_genre: str
|
||||
unformatted_location: str
|
||||
|
||||
artwork: List[Artwork]
|
||||
|
||||
source_collection: SourceCollection
|
||||
contact_collection: Collection[Contact]
|
||||
|
||||
@ -493,6 +495,8 @@ class Artist(Base):
|
||||
"lyrical_themes": list,
|
||||
"general_genre": lambda: "",
|
||||
|
||||
"artwork": list,
|
||||
|
||||
"source_collection": SourceCollection,
|
||||
"album_collection": Collection,
|
||||
"contact_collection": Collection,
|
||||
@ -511,6 +515,7 @@ class Artist(Base):
|
||||
notes: FormattedText = None,
|
||||
lyrical_themes: List[str] = None,
|
||||
general_genre: str = None,
|
||||
artwork: List[Artwork] = None,
|
||||
unformatted_location: str = None,
|
||||
source_list: List[Source] = None,
|
||||
contact_list: List[Contact] = None,
|
||||
|
@ -457,17 +457,17 @@ class Musify(Page):
|
||||
for album_info in soup.find_all("ul", {"class": "album-info"}):
|
||||
list_element: BeautifulSoup = album_info.find("li")
|
||||
|
||||
if list_element is not None:
|
||||
artist_soup: BeautifulSoup
|
||||
for artist_soup in list_element.find_all("a"):
|
||||
artist_source_list = []
|
||||
href = artist_soup["href"]
|
||||
if href is not None:
|
||||
artist_source_list = [Source(self.SOURCE_TYPE, self.HOST + href)]
|
||||
artist_list.append(Artist(
|
||||
name=artist_soup.text.strip(),
|
||||
source_list=artist_source_list
|
||||
))
|
||||
if list_element is not None:
|
||||
artist_soup: BeautifulSoup
|
||||
for artist_soup in list_element.find_all("a"):
|
||||
artist_source_list = []
|
||||
href = artist_soup["href"]
|
||||
if href is not None:
|
||||
artist_source_list = [Source(self.SOURCE_TYPE, self.HOST + href)]
|
||||
artist_list.append(Artist(
|
||||
name=artist_soup.text.strip(),
|
||||
source_list=artist_source_list
|
||||
))
|
||||
|
||||
# breadcrums
|
||||
breadcrumb_list_element_list: List[BeautifulSoup] = soup.find_all("ol", {"class": "breadcrumb"})
|
||||
@ -485,7 +485,7 @@ class Musify(Page):
|
||||
|
||||
track_name = list_points[4].text.strip()
|
||||
|
||||
# artwork
|
||||
# album artwork
|
||||
artwork: Artwork = Artwork()
|
||||
album_image_element_list: List[BeautifulSoup] = soup.find_all("img", {"class": "album-img"})
|
||||
for album_image_element in album_image_element_list:
|
||||
@ -918,7 +918,8 @@ class Musify(Page):
|
||||
name=name,
|
||||
country=country,
|
||||
source_list=source_list,
|
||||
notes=notes
|
||||
notes=notes,
|
||||
artwork=self._fetch_artist_artwork(soup, **kwargs)
|
||||
)
|
||||
|
||||
def _parse_album_card(self, album_card: BeautifulSoup, artist_name: str = None, **kwargs) -> Album:
|
||||
@ -1056,6 +1057,20 @@ class Musify(Page):
|
||||
|
||||
artist.album_collection.append(album)
|
||||
|
||||
def _fetch_artist_artwork(self, soup: BeautifulSoup, **kwargs):
|
||||
# artist artwork
|
||||
artist_artwork: List[Artwork] = Artwork()
|
||||
artist_a_element_list: List[BeautifulSoup] = soup.find_all("a")
|
||||
for artist_a_element in artist_a_element_list:
|
||||
if artist_a_element.find_all("img", {"class": "artist-img"}).count() > 0:
|
||||
artwork_gallery = self.connection.get(artist_a_element("data-src", artist_a_element.get("href")))
|
||||
if artwork_gallery is not None:
|
||||
gallery_image_element_list: List[BeautifulSoup] = artwork_gallery.find_all("img", {"class": "artist-img"})
|
||||
for gallery_image_element in gallery_image_element_list:
|
||||
artist_artwork.push(Artwork(url=gallery_image_element.get("data-src", gallery_image_element.get("src"))))
|
||||
|
||||
return artist_artwork
|
||||
|
||||
def fetch_artist(self, source: Source, **kwargs) -> Artist:
|
||||
"""
|
||||
TODO
|
||||
@ -1068,7 +1083,7 @@ class Musify(Page):
|
||||
|
||||
artist = self._fetch_initial_artist(url, source=source, **kwargs)
|
||||
self._fetch_artist_discography(artist, url, artist.name, **kwargs)
|
||||
|
||||
self._fetch_artist_artwork(artist, **kwargs)
|
||||
return artist
|
||||
|
||||
def fetch_label(self, source: Source, stop_at_level: int = 1) -> Label:
|
||||
|
Loading…
Reference in New Issue
Block a user