mirror of
https://github.com/beetbox/beets.git
synced 2026-01-13 03:34:31 +01:00
Genius lyrics header bug fixed and updated test case for lyrics plugin
This commit is contained in:
parent
e977a6f799
commit
c0bb2ff2a1
3 changed files with 871 additions and 3 deletions
|
|
@ -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()
|
||||
|
||||
|
||||
|
|
|
|||
864
test/rsrc/lyrics/geniuscom/Ttngchinchillalyrics.txt
Normal file
864
test/rsrc/lyrics/geniuscom/Ttngchinchillalyrics.txt
Normal file
File diff suppressed because one or more lines are too long
|
|
@ -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)))
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue