johnwmillr / LyricsGenius

Download song lyrics and metadata from Genius.com 🎶🎤
http://www.johnwmillr.com/scraping-genius-lyrics/
MIT License
878 stars 159 forks source link

[fix] fix for extra text at last line of lyrics #215

Open gautamajay52 opened 3 years ago

gautamajay52 commented 3 years ago

Most of the times the last line of lyrics has EmbedShare Url:CopyEmbed:Copy as extra words.

johnwmillr commented 3 years ago

Hi @gautamajay52, could you provide a couple of examples of lyrics returning those extra words? Thanks!

gautamajay52 commented 3 years ago

Hi @gautamajay52, could you provide a couple of examples of lyrics returning those extra words? Thanks!

I am not getting in all songs. I am integrating this with Spotify to get the current playing lyrics.

Here is HTMl that I used to get when that text appear for me while testing.

But on requesting again sometimes it doesn't appear. So it is random, but I have noticed it with a lot of songs.

gautamajay52 commented 3 years ago

Hi @gautamajay52, could you provide a couple of examples of lyrics returning those extra words? Thanks!

Here is another HTML I just got again while testing.

Sir you can find the name of song in this html.

edit: html of same song when I don't get that extra text.

gautamajay52 commented 3 years ago

Hi @gautamajay52, could you provide a couple of examples of lyrics returning those extra words? Thanks!

Sir ! Are you able to reproduce the error? Do I have to provide any other details?

jam0ra commented 2 years ago

I seem to be having this issue as well with songs such as "Say So" and "Kiss Me More" by Doja Cat.

gautamajay52 commented 2 years ago

@johnwmillr I seem to be having this issue as well with songs such as "Say So" and "Kiss Me More" by Doja Cat.

Hey, Have you tried this fix ?

jam0ra commented 2 years ago

@gautamajay52 Yup seems to work fine so far!

gautamajay52 commented 2 years ago

@gautamajay52 Yup seems to work fine so far!

Actually, I was getting in almost all songs after doing multiple requests on the same song. Thanks for your review.

iiKurt commented 2 years ago

There also appears to be extra header text prepended to the first line, too. When getting the div on line 137, this is what is outputted. Line one has the extra text "Mood Lyrics" in an h2 element.

Changing the pull request to this would fix both the original and this issue:

else:
    rem = div.find("div", class_=re.compile("Lyrics__Footer"))
    if rem:
        rem.replace_with("")

    header = div.find("h2", class_=re.compile("TextLabel"))
    if header:
        header.replace_with("")
Acervans commented 1 year ago

There also appears to be extra header text prepended to the first line, too. When getting the div on line 137, this is what is outputted. Line one has the extra text "Mood Lyrics" in an h2 element.

Changing the pull request to this would fix both the original and this issue:

else:
    rem = div.find("div", class_=re.compile("Lyrics__Footer"))
    if rem:
        rem.replace_with("")

    header = div.find("h2", class_=re.compile("TextLabel"))
    if header:
        header.replace_with("")

Some songs with translated lyrics also have some extra text at the beginning. I solved it with:

else:
    rem = div.find("div", class_=re.compile("Lyrics__Footer"))
    if rem:
        rem.replace_with("")

    header = div.find("h2", class_=re.compile("TextLabel"))
    if header:
        header.replace_with("")

    controls = div.find("div", class_=re.compile("LyricsControls"))
    if controls:
        controls.replace_with("")