Genius lyrics header bug fixed and updated test case for lyrics plugin

This commit is contained in:
olgarrahan 2022-04-15 16:37:05 -04:00
parent e977a6f799
commit c0bb2ff2a1
3 changed files with 871 additions and 3 deletions

View file

@ -401,7 +401,12 @@ class Genius(Backend):
# all of the lyrics can be found already correctly formatted
# Sometimes, though, it packages the lyrics into separate divs, most
# likely for easier ad placement
lyrics_div = soup.find("div", class_="lyrics")
lyrics_div = soup.find("div", {"data-lyrics-container": True})
for br in lyrics_div.find_all("br"):
br.replace_with("\n")
if not lyrics_div:
self._log.debug('Received unusual song page html')
verse_div = soup.find("div",
@ -429,7 +434,6 @@ class Genius(Backend):
class_=re.compile("Lyrics__Footer"))
for footer in footers:
footer.replace_with("")
return lyrics_div.get_text()

File diff suppressed because one or more lines are too long

View file

@ -457,7 +457,7 @@ class GeniusScrapeLyricsFromHtmlTest(GeniusBaseTest):
def test_good_lyrics(self):
"""Ensure we are able to scrape a page with lyrics"""
url = 'https://genius.com/Wu-tang-clan-cream-lyrics'
url = 'https://genius.com/Ttng-chinchilla-lyrics'
mock = MockFetchUrl()
self.assertIsNotNone(genius._scrape_lyrics_from_html(mock(url)))