Merge pull request #4229 from ybnd/pr_fix-tekstowo-scraper

Minor fixes to lyrics scrapers
This commit is contained in:
Adrian Sampson 2022-01-10 16:08:47 -08:00 committed by GitHub
commit b3100415fc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View file

@ -419,11 +419,17 @@ class Genius(Backend):
lyrics_div = verse_div.parent
for br in lyrics_div.find_all("br"):
br.replace_with("\n")
ads = lyrics_div.find_all("div",
class_=re.compile("InreadAd__Container"))
for ad in ads:
ad.replace_with("\n")
footers = lyrics_div.find_all("div",
class_=re.compile("Lyrics__Footer"))
for footer in footers:
footer.replace_with("")
return lyrics_div.get_text()
@ -488,11 +494,11 @@ class Tekstowo(Backend):
if not soup:
return None
lyrics_div = soup.find("div", class_="song-text")
lyrics_div = soup.select("div.song-text > div.inner-text")
if not lyrics_div:
return None
return lyrics_div.get_text()
return lyrics_div[0].get_text()
def remove_credits(text):

View file

@ -35,6 +35,8 @@ Bug fixes:
* :doc:`plugins/web`: Fix handling of "query" requests. Previously queries
consisting of more than one token (separated by a slash) always returned an
empty result.
* :doc:`plugins/lyrics`: Fixed issues with the Tekstowo.pl and Genius
backends where some non-lyrics content got included in the lyrics
For packagers: