mirror of
https://github.com/KevinMidboe/spotify-downloader.git
synced 2025-10-29 18:00:15 +00:00
Fix crash when lyrics not yet released on Genius
There are some tracks on Genius whose lyrics are yet to be released. When the tool previously attempted to scrape such webpages, it resulted in a crash. The tool will now raise an exception; LyricNotFoundError when such a track is encountered, which is then handled internally by the tool. Example of one such track on Genius: https://genius.com/The-federal-empire-good-man-lyrics Fixes #647.
This commit is contained in:
@@ -37,8 +37,10 @@ class Genius(LyricBase):
|
||||
def _get_lyrics_text(self, html):
|
||||
soup = BeautifulSoup(html, "html.parser")
|
||||
lyrics_paragraph = soup.find("p")
|
||||
lyrics = lyrics_paragraph.get_text()
|
||||
return lyrics
|
||||
if lyrics_paragraph:
|
||||
return lyrics_paragraph.get_text()
|
||||
else:
|
||||
raise LyricsNotFound("The lyrics for this track are yet to be released.")
|
||||
|
||||
def get_lyrics(self, linesep="\n", timeout=None):
|
||||
url = self._guess_lyric_url()
|
||||
|
||||
Reference in New Issue
Block a user