From 688b4fd357b2d927af78e2b5731b270977a15038 Mon Sep 17 00:00:00 2001 From: Lars Noack Date: Tue, 21 May 2024 16:47:38 +0200 Subject: [PATCH] feat: getting the album tracklist --- music_kraken/objects/formatted_text.py | 8 ++++++++ music_kraken/pages/genius.py | 13 ++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/music_kraken/objects/formatted_text.py b/music_kraken/objects/formatted_text.py index 99e9ae2..6acb86e 100644 --- a/music_kraken/objects/formatted_text.py +++ b/music_kraken/objects/formatted_text.py @@ -37,11 +37,19 @@ class FormattedText: @property def markdown(self) -> str: return md(self.html).strip() + + @markdown.setter + def markdown(self, value: str) -> None: + self.html = mistune.markdown(value) @property def plain(self) -> str: md = self.markdown return md.replace("\n\n", "\n") + + @plain.setter + def plain(self, value: str) -> None: + self.html = mistune.markdown(plain_to_markdown(value)) def __str__(self) -> str: return self.markdown diff --git a/music_kraken/pages/genius.py b/music_kraken/pages/genius.py index e17aea9..8c8a15f 100644 --- a/music_kraken/pages/genius.py +++ b/music_kraken/pages/genius.py @@ -99,7 +99,7 @@ class Genius(Page): elif "markdown" in description: notes.markdown = description["markdown"] elif "description_preview" in data: - notes.plain = data["description_preview"] + notes.plaintext = data["description_preview"] if source.url is None: return None @@ -126,7 +126,7 @@ class Genius(Page): for cover_art in data.get("cover_arts", []): self.add_to_artwork(artwork, cover_art.get("image_url")) self.add_to_artwork(artwork, cover_art.get("thumbnail_image_url")) - + return Album( title=data.get("name").strip(), source_list=[source], @@ -244,7 +244,14 @@ class Genius(Page): data = json.loads(content) album = self.parse_api_object(data.get("album", {})) - + + for e in data.get("album_appearances", []): + r = self.parse_api_object(e.get("song")) + if not isinstance(r, Song): + continue + + album.song_collection.append(r) + album.source_collection.append(source) return album