From bf04d5b8bec38aaff7ae75b5ab3fe6c7d038b106 Mon Sep 17 00:00:00 2001 From: Hellow2 Date: Fri, 17 Mar 2023 12:39:19 +0100 Subject: [PATCH] Update musify.py --- src/music_kraken/pages/musify.py | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/src/music_kraken/pages/musify.py b/src/music_kraken/pages/musify.py index 0a0afb3..4a04c05 100644 --- a/src/music_kraken/pages/musify.py +++ b/src/music_kraken/pages/musify.py @@ -419,16 +419,26 @@ class Musify(Page): name: str = "" source_list: List[Source] = [] - - anchor_list = album_card.find_all("a", recursive=False) - if len(anchor_list) > 0: - anchor = anchor_list[0] + def parse_release_anchor(anchor: BeautifulSoup, text_is_name=False): + if anchor is None: + return source_list.append(Source( cls.SOURCE_TYPE, 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") if thumbnail is not None: alt = thumbnail.get("alt") @@ -436,10 +446,22 @@ class Musify(Page): name = alt image_url = thumbnail.get("src") - else: 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 def get_discography(cls, url: MusifyUrl) -> List[Album]: