Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with "get_lyrics_id()" #21

Open
giovanni-cutri opened this issue May 7, 2023 · 10 comments · May be fixed by #22
Open

Error with "get_lyrics_id()" #21

giovanni-cutri opened this issue May 7, 2023 · 10 comments · May be fixed by #22

Comments

@giovanni-cutri
Copy link

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
Copy link

cschwem2er commented May 11, 2023

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
Copy link
Author

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.

@giovanni-cutri giovanni-cutri linked a pull request May 23, 2023 that will close this issue
@dsanchezp18
Copy link

I'm also having the same error.

@danhart228
Copy link

I'm Also having this problem

@ewenme
Copy link
Owner

ewenme commented Jun 12, 2023

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
Copy link

danhart228 commented Jun 12, 2023 via email

@TFCampos
Copy link

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
Copy link

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
Copy link

d-qn commented Jun 23, 2023

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

@AaronPhilipp
Copy link

AaronPhilipp commented May 10, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants