JosiahParry/genius

genius_album_url and other functions has problem with letter 'o'

byrdas opened this issue · 17 comments

Hey,

Working with your package I found, that I cannot generate songs, lyrics and etc from albums/artists where i have letter 'o' in their name/title. Please find below example. (I broke into details function genius_album_url and found this case):

Original function looks like:

gen_album_url

function (artist = NULL, album = NULL)
{
artist <- prep_info(artist)
album <- prep_info(album)
base_url <- "https://genius.com/albums/"
query <- paste(artist, "/", album, sep = "") %>%
str_replace_all(" ", "-")
url <- paste0(base_url, query)
return(url)
}

Let:
_artist <- "Eminem"
album <- 'Music to Be Murdered by'
then
> url
"https://genius.com/albums/Eminem/Music-to-Be-Murdered-by"

But if I directly use:
gen_album_url(artist='Eminem', album='Music to Be Murdered by')

I have this output:
"https://genius.com/albums/Eminem/Music-t-Be-Murdered-by"
(letter 'o' disappear from 'to'

Another Example:
> gen_album_url(artist='Madonna', album='GHV2')
[1] "https://genius.com/albums/Madnna/GHV2"

(letter 'o' disappear from Madonna)

As you can see, letter 'o' disappear from both cases, in artist name and in album title. And this is the reason of errors using genius_tracklist, genius_album and other. (...Not Found (HTTP 404))

Hi @byrdas,

First off, I'm super glad you're able to use the package!

It looks like that this actually may be an issue with either your R installation or the text encoding that you're using. I'm sure I would've encountered this problem in the past!

Below is a reprex with the Eminem example and the url string that gen_album_url() creates.
Moreover, genius::genius_album("Eminem", "Music to be Murdered by") also works.

Can you provide the sessionInfo() as well as the R package version you're using?

genius:::gen_album_url(artist = "Eminem", album = "Music to Be Murdered by")
#> [1] "https://genius.com/albums/Eminem/Music-to-Be-Murdered-by"

Created on 2020-04-25 by the reprex package (v0.3.0)

Please find below my sessionInfo:

R version 3.6.2 (2019-12-12)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362)

Matrix products: default

locale:
[1] LC_COLLATE=English_United Kingdom.1252 LC_CTYPE=English_United Kingdom.1252 LC_MONETARY=English_United Kingdom.1252
[4] LC_NUMERIC=C

And I use genius_2.2.1

> genius:::gen_album_url(artist = "Eminem", album = "Music to Be Murdered by")
[1] "https://genius.com/albums/Eminem/Music-t-Be-Murdered-by"

It looks like you need to set your locale to utf-8.
Try running Sys.setlocale(locale = "utf-8") to set the locale to utf-8 and then try it.

I am working on Windows 10 and generally I have no idea how to change it. All the time I have the same error:

Warning message:
In Sys.setlocale(locale = "utf-8") :
OS reports request to set locale to "utf-8" cannot be honored

Do you have any ideas how to change it on Windows? I will be very appreciated for your help

Can you check your default text encoding? Global Tools > Code > Saving > Default Text Encoding.

I was trying different (WINDOWS1252, ISO-8859-1 UTF8), . Now I have UTF-8. And all the time letter 'o' is missed.
Very strange, because when I simply define variable with value 'o' it does not disappear:

> abc <- "ooooooo"
> abc
[1] "ooooooo"

This is a bit outside of my wheelhouse. It might be worth asking a question in community.rstudio.com about this. I'm sure you're not the only windows user with this problem. Can you share what version of RStudio you're running? Is it 1.2.x?

I use - Version 1.2.5033

Does the code run properly or is it just not printing?
The community post makes it seem that it's just printhing that may be borked. https://community.rstudio.com/t/rstudio-ide-inconsistently-displaying-some-characters/5135/2

I have error because of this fact:

> emotions_math <- genius::genius_album("Eminem",
+                                       "Music to Be Murdered by")
Error in read_xml.response(x$response, ..., as_html = as_html) : 
  Not Found (HTTP 404).
In addition: Warning message:
In request_GET(session, url) : Not Found (HTTP 404).

When I am searching something without 'o', everything is ok, and I get results

Yes. I was trying different ones. And the same error occur. Now I have UTF-8

Ok. Thanks for your time and help

Could be interesting for you. When I use upper 'O' it works:

> genalbumurl('Madonna', "GHV2")
[1] "https://genius.com/albums/Madnna/GHV2"
> genalbumurl('MADONNA', "GHV2")
[1] "https://genius.com/albums/MADONNA/GHV2"

All the function works if I type artist/album in uppercase

I feel like I should've mentioned this earlier. But genius has essentially an escape hatch via genius_url() if you can find a way to make your own track urls you can pass those as a character vector.