Update musify.py

This commit is contained in:
Hellow2 2023-03-17 12:39:19 +01:00
parent 7b110983c2
commit bf04d5b8be

View File

@ -419,16 +419,26 @@ class Musify(Page):
name: str = "" name: str = ""
source_list: List[Source] = [] source_list: List[Source] = []
def parse_release_anchor(anchor: BeautifulSoup, text_is_name=False):
anchor_list = album_card.find_all("a", recursive=False) if anchor is None:
if len(anchor_list) > 0: return
anchor = anchor_list[0]
source_list.append(Source( source_list.append(Source(
cls.SOURCE_TYPE, cls.SOURCE_TYPE,
cls.HOST + anchor.get("href") cls.HOST + anchor.get("href")
)) ))
if not text_is_name:
return
name = anchor.text
anchor_list = album_card.find_all("a", recursive=False)
if len(anchor_list) > 0:
anchor = anchor_list[0]
parse_release_anchor(anchor)
thumbnail: BeautifulSoup = anchor.find("img") thumbnail: BeautifulSoup = anchor.find("img")
if thumbnail is not None: if thumbnail is not None:
alt = thumbnail.get("alt") alt = thumbnail.get("alt")
@ -436,10 +446,22 @@ class Musify(Page):
name = alt name = alt
image_url = thumbnail.get("src") image_url = thumbnail.get("src")
else: else:
LOGGER.debug("the card has no thumbnail or url") LOGGER.debug("the card has no thumbnail or url")
card_body = album_card.find("div", {"class": "card-body"})
if card_body is not None:
parse_release_anchor(card_body.find("a"), text_is_name=True)
card_footer_list = album_card.find_all("div", {"class": "card-footer"})
return Album(
title=name,
source_list=source_list
)
@classmethod @classmethod
def get_discography(cls, url: MusifyUrl) -> List[Album]: def get_discography(cls, url: MusifyUrl) -> List[Album]: