Skip to content

Commit

Permalink
change lyrics scraper to use Lyrics__Container to get rid of metadata (
Browse files Browse the repository at this point in the history
  • Loading branch information
thedustyrover authored Aug 11, 2023
1 parent bec0266 commit a702f5f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lyricsgenius/genius.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,15 @@ def lyrics(self, song_id=None, song_url=None, remove_section_headers=False):
)

# Determine the class of the div
div = html.find("div", class_=re.compile("^lyrics$|Lyrics__Root"))
if div is None:
divs = html.find_all("div", class_=re.compile("^lyrics$|Lyrics__Container"))
if divs is None or len(divs) <= 0:
if self.verbose:
print("Couldn't find the lyrics section. "
"Please report this if the song has lyrics.\n"
"Song URL: https://genius.com/{}".format(path))
return None

lyrics = div.get_text()
lyrics = "\n".join([div.get_text() for div in divs])

# Remove [Verse], [Bridge], etc.
if self.remove_section_headers or remove_section_headers:
Expand Down

0 comments on commit a702f5f

Please sign in to comment.