From a97f8872c8eed63016a7f61f9ab9f715b8e7bc96 Mon Sep 17 00:00:00 2001 From: Lars Noack Date: Wed, 8 May 2024 09:57:11 +0200 Subject: [PATCH] fix: refetching release title from album card --- music_kraken/pages/musify.py | 47 ++++++------------------------------ 1 file changed, 7 insertions(+), 40 deletions(-) diff --git a/music_kraken/pages/musify.py b/music_kraken/pages/musify.py index a5c3f10..ebcb8e6 100644 --- a/music_kraken/pages/musify.py +++ b/music_kraken/pages/musify.py @@ -935,34 +935,6 @@ class Musify(Page): "source_list": [], } - name: str = None - source_list: List[Source] = [] - timestamp: Optional[ID3Timestamp] = None - album_status = None - - def set_name(new_name: str): - nonlocal album_kwargs - nonlocal name - nonlocal artist_name - - # example of just setting not working: - # https://musify.club/release/unjoy-eurythmie-psychonaut-4-tired-numb-still-alive-2012-324067 - if new_name.count(" - ") != 1: - name = new_name - return - - potential_artist_list, potential_name = new_name.split(" - ") - unified_artist_list = string_processing.unify(potential_artist_list) - if artist_name is not None: - if string_processing.unify(artist_name) not in unified_artist_list: - name = new_name - return - - name = potential_name - return - - name = new_name - album_status_id = album_card.get("data-type") if album_status_id.isdigit(): album_status_id = int(album_status_id) @@ -973,8 +945,6 @@ class Musify(Page): def parse_release_anchor(_anchor: BeautifulSoup, text_is_name=False): nonlocal album_kwargs - nonlocal name - nonlocal source_list if _anchor is None: return @@ -987,6 +957,9 @@ class Musify(Page): self.HOST + href )) + if text_is_name: + album_kwargs["title"] = clean_song_title(_anchor.text, artist_name) + anchor_list = album_card.find_all("a", recursive=False) if len(anchor_list) > 0: anchor = anchor_list[0] @@ -996,7 +969,7 @@ class Musify(Page): if thumbnail is not None: alt = thumbnail.get("alt") if alt is not None: - set_name(alt) + album_kwargs["title"] = clean_song_title(alt, artist_name) image_url = thumbnail.get("src") else: @@ -1013,7 +986,7 @@ class Musify(Page): 13.11.2021 """ - nonlocal timestamp + nonlocal album_kwargs italic_tagging_soup: BeautifulSoup = small_soup.find("i") if italic_tagging_soup is None: @@ -1023,7 +996,7 @@ class Musify(Page): return raw_time = small_soup.text.strip() - timestamp = ID3Timestamp.strptime(raw_time, "%d.%m.%Y") + album_kwargs["date"] = ID3Timestamp.strptime(raw_time, "%d.%m.%Y") # parse small date card_footer_list = album_card.find_all("div", {"class": "card-footer"}) @@ -1036,13 +1009,7 @@ class Musify(Page): else: self.LOGGER.debug("there is not even 1 footer in the album card") - return Album( - title=name, - source_list=source_list, - date=timestamp, - album_type=album_type, - album_status=album_status, - ) + return Album(**album_kwargs) def _fetch_artist_discography(self, artist: Artist, url: MusifyUrl, artist_name: str = None, **kwargs): """