LyricsGenius icon indicating copy to clipboard operation
LyricsGenius copied to clipboard

genius.lyrics is returning unwanted data in requests

Open treyhamilton opened this issue 6 months ago • 0 comments

Describe the bug Hi, I am attempting to use the genius API in order to get various song lyrics. While I have most of it all working, there is one small issue that is a pain to work around. When making my request for my songs, I notice two bugs. 1 At the very top of the returned text(lyrics) there is usually some meta data that looks like this, '27ContributorsTranslationsPortuguêsDeutschCatalàFrançaisEspañolLast Night Lyrics'. This to me looks like meta data and is not a part of the actual lyrics. 2, within the lyrics, there are random pieces of text that show up based on what I believe are advertisements within the actual webpage. For example, 'See Morgan Wallen LiveGet tickets as low as $17You might also like' which is once again not apart of the lyrics. Finally, at the very end of each song, there is the following '3Embed' added on to the end of the lyrics.

Expected behavior The expected outcome is to only have just the lyrics returned with appropriate spacing and no words other than those actually in the lyrics. This will then be outputted to a .txt file.

To Reproduce Describe the steps required to reproduce the behavior.

  1. setup the genius API
  2. Just run the following one line of code and you will reproduce the same error I am getting, very simple.

Include the error message associated with the bug.

Version info

  • Version is 3.0.1
  • OS: macOS

Additional context The following is the code....

import lyricsgenius

# Add your Genius API token here
genius = lyricsgenius.Genius(client_access_token)
artist_name = 'Morgan Wallen'

#artist = genius.search_artist(artist_name, max_songs=10, sort='popularity', per_page=20, get_full_info=True, allow_name_change=True, artist_id=None, include_features=False)
artist = genius.search_artist(artist_name, max_songs=10, sort='popularity', per_page=20, get_full_info=False, allow_name_change=True, artist_id=None, include_features=False)
for song in artist.songs:
    print(song.id)
last_night = genius.lyrics(song_id=8779646, song_url=None, remove_section_headers=True)
print(last_night)

OUTPUT:

27 ContributorsTranslationsPortuguêsDeutschCatalàFrançaisEspañolLast Night Lyrics
Last night, we let the liquor talk
I can't remember everything we said, but we said it all
You told me that you wish I was somebody you never met
But, baby, baby, something's tellin' me this ain't over yet

No way it was our last night I kissed your lips
Make you grip the sheets with your fingertips
Last bottle of Jack, we split a fifth
Just talkin' 'bout life, goin' sip for sip
Yeah, you, you know you love to fight
And I say shit I don't mean
But I'm still gon' wake up wantin' you and me

I know that last night, we let the liquor talk
I can't remember everything we said, but we said it all
You told me that you wish I was somebody you never met
But, baby, baby, something's tellin' me this ain't over yet
No way it was our last night (Last night)
No way it was our last night (Last night)

No way it was the last night that we break up
I see your tail lights in the dust
You call your mama, I call your bluff
In the middle of the night, pull it right back up
Yeah, my, my friends say, "Let her go"
Your friends say, "What the hell?"
I wouldn't trade your kind of love for nothin' else
See Morgan Wallen LiveGet tickets as low as $17You might also like
Oh, baby, last night, we let the liquor talk
I can't remember everything we said, but we said it all
You told me that you wish I was somebody you never met
But, baby, baby, something's tellin' me this ain't over yet
No way it was our last night, we said we'd had enough
I can't remember everything we said, but we said too much
I know you packed your shit and slammed the door right before you left
But, baby, baby, something's tellin' me this ain't over yet
No way it was our last night (Last night)
No way it was our last night (Last night)

I know you said this time you really weren't comin' back again
But, baby, baby, something's tellin' me this ain't over yet
No way it was our last night (Last night)
No way it was our last night (Last night)3Embed

The lines

  • 27 ContributorsTranslationsPortuguêsDeutschCatalàFrançaisEspañolLast Night Lyrics
  • See Morgan Wallen LiveGet tickets as low as $17You might also like
  • 3Embed

above should not be included. Any help here would be great as I am trying to make a reliable function that can handle this so I am not having to regex everything out. Thanks in advance!

treyhamilton avatar Dec 27 '23 19:12 treyhamilton