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

@ -38,11 +38,19 @@ class FormattedText:
def markdown(self) -> str: def markdown(self) -> str:
return md(self.html).strip() return md(self.html).strip()
@markdown.setter
def markdown(self, value: str) -> None:
self.html = mistune.markdown(value)
@property @property
def plain(self) -> str: def plain(self) -> str:
md = self.markdown md = self.markdown
return md.replace("\n\n", "\n") 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: def __str__(self) -> str:
return self.markdown return self.markdown

View File

@ -99,7 +99,7 @@ class Genius(Page):
elif "markdown" in description: elif "markdown" in description:
notes.markdown = description["markdown"] notes.markdown = description["markdown"]
elif "description_preview" in data: elif "description_preview" in data:
notes.plain = data["description_preview"] notes.plaintext = data["description_preview"]
if source.url is None: if source.url is None:
return None return None
@ -245,6 +245,13 @@ class Genius(Page):
album = self.parse_api_object(data.get("album", {})) 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) album.source_collection.append(source)
return album return album