feat: better lyrics support
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Hazel 2024-05-21 17:55:08 +02:00
parent 7b4eee858a
commit 90f70638b4

View File

@ -280,6 +280,10 @@ class Genius(Page):
content = content.replace("\\\\", "\\").replace('\\"', '"').replace("\\'", "'") content = content.replace("\\\\", "\\").replace('\\"', '"').replace("\\'", "'")
data = json.loads(content) 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) dump_to_file("genius_song_script_json.json", content, is_json=True, exit_after_dump=False)
soup = self.get_soup_from_response(r) soup = self.get_soup_from_response(r)
@ -289,8 +293,3 @@ class Genius(Page):
song.source_collection.append(source) song.source_collection.append(source)
return song 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)