feat: getting the album tracklist
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Hazel 2024-05-21 16:47:38 +02:00
parent 769d27dc5c
commit 688b4fd357
2 changed files with 18 additions and 3 deletions

View File

@ -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

View File

@ -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