From 90f70638b4b288421be9d646ddc38dd1a9d7a979 Mon Sep 17 00:00:00 2001 From: Lars Noack Date: Tue, 21 May 2024 17:55:08 +0200 Subject: [PATCH] feat: better lyrics support --- music_kraken/pages/genius.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/music_kraken/pages/genius.py b/music_kraken/pages/genius.py index 885aed8..0664ac4 100644 --- a/music_kraken/pages/genius.py +++ b/music_kraken/pages/genius.py @@ -280,6 +280,10 @@ class Genius(Page): content = content.replace("\\\\", "\\").replace('\\"', '"').replace("\\'", "'") data = json.loads(content) + lyrics_html = traverse_json_path(data, "songPage.lyricsData.body.html", default=None) + if lyrics_html is not None: + song.lyrics_collection.append(Lyrics(FormattedText(html=lyrics_html))) + dump_to_file("genius_song_script_json.json", content, is_json=True, exit_after_dump=False) soup = self.get_soup_from_response(r) @@ -289,8 +293,3 @@ class Genius(Page): song.source_collection.append(source) return song - - def download_song_to_target(self, source: Source, target: Target, desc: str = None) -> DownloadResult: - if source.audio_url is None: - return DownloadResult(error_message="Couldn't find download link.") - return self.connection.stream_into(url=source.audio_url, target=target, description=desc)