From 81708ba100d47dedd9c73cbccdde2adf4bbb1083 Mon Sep 17 00:00:00 2001 From: Lars Noack Date: Fri, 19 Apr 2024 13:51:08 +0200 Subject: [PATCH] feat: switched to a more readable markdown converter --- music_kraken/objects/formatted_text.py | 4 ++-- music_kraken/pages/bandcamp.py | 1 - pyproject.toml | 1 + 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/music_kraken/objects/formatted_text.py b/music_kraken/objects/formatted_text.py index 6d95389..8c01d39 100644 --- a/music_kraken/objects/formatted_text.py +++ b/music_kraken/objects/formatted_text.py @@ -1,5 +1,5 @@ import mistune -import html2markdown +from markdownify import markdownify as md def plain_to_markdown(plain: str) -> str: @@ -36,7 +36,7 @@ class FormattedText: @property def markdown(self) -> str: - return html2markdown.convert(self.html) + return md(self.html) def __str__(self) -> str: return self.markdown diff --git a/music_kraken/pages/bandcamp.py b/music_kraken/pages/bandcamp.py index 52142eb..1088be0 100644 --- a/music_kraken/pages/bandcamp.py +++ b/music_kraken/pages/bandcamp.py @@ -333,7 +333,6 @@ class Bandcamp(Page): def _fetch_lyrics(self, soup: BeautifulSoup) -> List[Lyrics]: track_lyrics = soup.find("div", {"class": "lyricsText"}) if track_lyrics: - self.LOGGER.debug(" Lyrics retrieved..") return [Lyrics(text=FormattedText(html=track_lyrics.prettify()))] return [] diff --git a/pyproject.toml b/pyproject.toml index 5fab835..16fac20 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -56,6 +56,7 @@ dependencies = [ "rich~=13.7.1", "mistune~=3.0.2", + "markdownify~=0.12.1", "html2markdown~=0.1.7", "jellyfish~=0.9.0", "transliterate~=1.10.2",