ewenme / geniusr

work with data & lyrics from Genius
https://ewenme.github.io/geniusr/
Other
49 stars 12 forks source link

Error with "get_lyrics_id()" #21

Open giovanni-cutri opened 1 year ago

giovanni-cutri commented 1 year ago

Hello, when using the function get_lyrics_id, I get this error message in the R console:

Error in section_artist[is.na(section_artist)] <- artist : 
  replacement has length zero

I have tested it with multiple songs and always get the same result.

Thanks for your help.

cschwem2er commented 1 year ago

Please double-check that you have not by accident used your Client ID instead of your Client Access Token: image I made this mistake myself and got the same error message before. With the Access Token, everything works flawlessly on my end.

giovanni-cutri commented 1 year ago

Thanks for your help, but it didn't work. I have correctly used my Client Access Token, but I still get the same error message.

dsanchezp18 commented 1 year ago

I'm also having the same error.

danhart228 commented 1 year ago

I'm Also having this problem

ewenme commented 1 year ago

it looks like @giovanni-cutri has submitted a PR that fixes this, but I'm not sure when I'll get round to looking at it. You can try installing the package from that branch, in the meantime.

danhart228 commented 1 year ago

Perfect! many thanks!

Daniel Hart University Professor Rutgers University


From: ewen @.> Sent: Monday, June 12, 2023 1:59 PM To: ewenme/geniusr @.> Cc: Daniel Hart @.>; Comment @.> Subject: Re: [ewenme/geniusr] Error with "get_lyrics_id()" (Issue #21)

it looks like @giovanni-cutrihttps://github.com/giovanni-cutri has submitted a PR that fixes this, but I'm not sure when I'll get round to looking at it. You can try installing the package from that branch, in the meantime.

— Reply to this email directly, view it on GitHubhttps://github.com/ewenme/geniusr/issues/21#issuecomment-1587812815, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A266SFDBSNE4GDL73CDEKSLXK5KGVANCNFSM6AAAAAAXY5XGBA. You are receiving this because you commented.Message ID: @.***>

TFCampos commented 1 year ago

I'm also having this problems, but not with get_lyric_id() function, but with get_lyrics_search().
I'm trying to run the example code in https://ewenme.github.io/geniusr/ , the one with Kenye West songs! I ran a debug on get_lyrics_search function, and I got this:

> debug(get_lyrics_search) 
> get_lyrics_search(artist_name = "Kanye West",
+                   song_title = "Good Morning")
debugging in: get_lyrics_search(artist_name = "Kanye West", song_title = "Good Morning")
debug: {
    artist_name <- str_replace_all(artist_name, bad_lyric_strings)
    song_title <- str_replace_all(song_title, bad_lyric_strings)
    path <- sprintf("https://genius.com/%s-%s-lyrics", artist_name, 
        song_title)
    check_internet()
    session <- read_html(path)
    get_lyrics(session)
}
Browse[2]> 
debug: artist_name <- str_replace_all(artist_name, bad_lyric_strings)
Browse[2]> 
debug: song_title <- str_replace_all(song_title, bad_lyric_strings)
Browse[2]> 
debug: path <- sprintf("https://genius.com/%s-%s-lyrics", artist_name, 
    song_title)
Browse[2]> 
debug: check_internet()
Browse[2]> 
debug: session <- read_html(path)
Browse[2]> 
debug: get_lyrics(session)
Browse[2]> 
Error in section_artist[is.na(section_artist)] <- artist : 
  replacement has length zero

Then I tried to run a debug on this get_lyric() and I got this:

> debug(get_lyrics)
Error: object 'get_lyrics' not found

I can't find this function.

I don't know what happend, but this used to work 5 months ago!

I'll try the @giovanni-cutri solution and I'll return with a feedback!

dsanchezp18 commented 1 year ago

I instaleld

I'm also having this problems, but not with get_lyric_id() function, but with get_lyrics_search(). I'm trying to run the example code in https://ewenme.github.io/geniusr/ , the one with Kenye West songs! I ran a debug on get_lyrics_search function, and I got this:

> debug(get_lyrics_search) 
> get_lyrics_search(artist_name = "Kanye West",
+                   song_title = "Good Morning")
debugging in: get_lyrics_search(artist_name = "Kanye West", song_title = "Good Morning")
debug: {
    artist_name <- str_replace_all(artist_name, bad_lyric_strings)
    song_title <- str_replace_all(song_title, bad_lyric_strings)
    path <- sprintf("https://genius.com/%s-%s-lyrics", artist_name, 
        song_title)
    check_internet()
    session <- read_html(path)
    get_lyrics(session)
}
Browse[2]> 
debug: artist_name <- str_replace_all(artist_name, bad_lyric_strings)
Browse[2]> 
debug: song_title <- str_replace_all(song_title, bad_lyric_strings)
Browse[2]> 
debug: path <- sprintf("https://genius.com/%s-%s-lyrics", artist_name, 
    song_title)
Browse[2]> 
debug: check_internet()
Browse[2]> 
debug: session <- read_html(path)
Browse[2]> 
debug: get_lyrics(session)
Browse[2]> 
Error in section_artist[is.na(section_artist)] <- artist : 
  replacement has length zero

Then I tried to run a debug on this get_lyric() and I got this:

> debug(get_lyrics)
Error: object 'get_lyrics' not found

I can't find this function.

I don't know what happend, but this used to work 5 months ago!

I'll try the @giovanni-cutri solution and I'll return with a feedback!

I was able to solve all issues from the @giovanni-cutri's solution :)

d-qn commented 1 year ago

Got the same error and @giovanni-cutri's fork fixed it, cheers

AaronPhilipp commented 1 month ago

The error occurs when in the function get_lyrics the artist is an empty vector. The html node which looks for the artist looks like an old one.

For me, a code change from: artist <- session %>% html_nodes(xpath = '//a[contains(@class, "SongHeaderdesktop__Artist")]') %>% html_text(trim = TRUE)

to: artist <- session %>% html_nodes(xpath = '//span[contains(@Class, "PortalTooltip__Container")]') %>% html_text(trim = TRUE) artist <- artist[1]

worked.