The purpose of this package is to provide an efficient method of downloading song lyrics using the ‘genius’ API.
You can install the development version of rgenius
from Github with:
remotes::install_github('AlbertoAlmuinha/rgenius')
To use the package it is necessary to obtain the ‘Genius’ API access token. You can get one by visiting the following link. All the functions in this package require the access_token
argument. You can pass it to each call manually, but our advice is to store it as an environment variable:
Sys.setenv(GENIUS_API_TOKEN = 'GENIUS_TOKEN')
The functions in this package require either the Artist ID or the Song ID. For this reason, the first step will be to obtain these ID’s. We achieve this with the search_genius_artist
andsearch_genius_song
functions.
library(rgenius) search_genius_artist(artist_name = 'Arctic Monkeys') %>% kable()
id |
name |
url |
image_url |
header_image_url |
is_verified |
is_meme_verified |
---|---|---|---|---|---|---|
12297 |
Arctic Monkeys |
https://images.genius.com/12c27f4fbb06ef32dc1c1e432098f447.570x570x1.jpg |
https://images.genius.com/b81ac6b3d864301390ef3d44f8095245.1000x563x1.jpg |
FALSE |
FALSE |
You can also get the ID of a song as follows:
search_genius_song(song_name = 'Paradise') %>% tail(3) %>% kable()
id |
name |
url |
full_title |
artist_id |
artist |
lyrics_state |
lyrics_owner_id |
song_art_image_url |
song_art_image_thumbnail_url |
---|---|---|---|---|---|---|---|---|---|
2343635 |
Paradise |
Paradise by Logic (Ft. Jesse Boykins III) |
7922 |
Logic |
complete |
172030 |
https://images.genius.com/b9b6844bdd8ebfbe10235ad54d885cfa.960x960x1.jpg |
https://images.genius.com/b9b6844bdd8ebfbe10235ad54d885cfa.300x300x1.jpg |
|
55882 |
Paradise |
Paradise by Coldplay |
8351 |
Coldplay |
complete |
30046 |
https://images.genius.com/8d4d307d9a6c211d1192c44a2cf6598d.1000x1000x1.png |
https://images.genius.com/8d4d307d9a6c211d1192c44a2cf6598d.300x300x1.png |
|
2843318 |
The Other Side of Paradise |
https://genius.com/Glass-animals-the-other-side-of-paradise-lyrics |
The Other Side of Paradise by Glass Animals |
87048 |
Glass Animals |
complete |
3642337 |
https://images.genius.com/f94989a22d577632d4f7b2aa084301f9.996x1000x1.jpg |
https://images.genius.com/f94989a22d577632d4f7b2aa084301f9.300x301x1.jpg |
Information from digital media where a song appears can be obtained from the get_song_media()
function. For example, let’s see what we get for Coldplay’s song ‘Paradise’ whose ID we got earlier:
get_song_media(song_id = '55882') %>% kable()
song_id |
provider |
type |
url |
---|---|---|---|
55882 |
youtube |
video |
|
55882 |
spotify |
audio |
|
55882 |
soundcloud |
audio |
https://soundcloud.com/coldplay/paradise?in=coldplay/sets/mylo-xyloto-4 |
Among the information obtained, we find the media that host this song and a direct link.
Information from the song’s music producers can be obtained as follows:
get_song_producer_artist(song_id = '55882') %>% kable()
song_id |
producer_id |
producer_name |
producer_url |
producer_img_url |
---|---|---|---|---|
55882 |
29971 |
Markus Dravs |
https://images.genius.com/7f6916eae6a76333e02b239b4145617d.468x468x1.jpg |
|
55882 |
112992 |
Daniel Green |
https://images.genius.com/fc80827d2d46226d42e9787575e4a4d0.300x350x1.jpg |
|
55882 |
29974 |
Rik Simpson |
https://images.genius.com/f6f7d70a2f2220f087b4af8482939714.1000x665x1.jpg |
|
55882 |
29972 |
Brian Eno |
https://images.genius.com/79c8742c09e5dafa22e970d3c3d15696.751x751x1.jpg |
Song lyrics can be obtained from the get_genius_song_lyrics()
function. Lyrics can be returned either in table format (tibble) or in text format (character vector).
get_genius_song_lyrics(song_id = '154314', output = 'tibble') %>% head(5) %>% kable()
Lyrics |
---|
Have you got colour in your cheeks?Do you ever get that fear that you can’t shift the type |
That sticks around like summat in your teeth?Are there some aces up your sleeve? |
Have you no idea that you’re in deep?I’ve dreamt about you nearly every night this week |
How many secrets can you keep?’Cause there’s this tune I found |
That makes me think of you somehow an’ I play it on repeatUntil I fall asleep, spillin’ drinks on my settee |
get_genius_song_lyrics(song_id = '154314', output = 'text') %>% kable()
x |
---|
Have you got colour in your cheeks?Do you ever get that fear that you can’t shift the type That sticks around like summat in your teeth?Are there some aces up your sleeve? Have you no idea that you’re in deep?I’ve dreamt about you nearly every night this week How many secrets can you keep?‘Cause there’s this tune I found That makes me think of you somehow an’ I play it on repeatUntil I fall asleep, spillin’ drinks on my settee (Do I wanna know?) If this feelin’ flows both ways? (Sad to see you go) Was sorta hopin’ that you’d stay(Baby, we both know) That the nights were mainly made For sayin’ things that you can’t say tomorrow day Crawlin’ back to you Ever thought of callin’ when You’ve had a few? ‘Cause I always doMaybe I’m too Busy bein’ yours To fall for somebody new Now, I’ve thought it through Crawlin’ back to you So have you got the guts?Been wonderin’ if your heart’s still open And if so, I wanna know what time it shutsSimmer down an’ pucker up, I’m sorry to interrupt It’s just I’m constantly on the cusp of tryin’ to kiss youI don’t know if you feel the same as I do But we could be together if you wanted to (Do I wanna know?) If this feelin’ flows both ways? (Sad to see you go) Was sorta hopin’ that you’d stay(Baby, we both know) That the nights were mainly made For sayin’ things that you can’t say tomorrow day Crawlin’ back to you (Crawlin’ back to you) Ever thought of callin’ when You’ve had a few? (Had a few) ‘Cause I always do (’Cause I always do)Maybe I’m too (Maybe I’m too busy) Busy bein’ yours (Bein’ yours) To fall for somebody new Now, I’ve thought it through Crawlin’ back to you (Do I wanna know?) If this feelin’ flows both ways? (Sad to see you go) Was sorta hopin’ that you’d stay(Baby, we both know) That the nights were mainly made For sayin’ things that you can’t say tomorrow day(Do I wanna know?) Too busy bein’ yours to fall(Sad to see you go) Ever thought of callin’, darlin’?(Do I wanna know?) Do you want me crawlin’ back to you? |
You can download the lyrics of an entire discography with the get_discography_lyrics()
function. This function uses parallel processing based on foreach
package to increase performance. Use the different cores of your device to achieve this, so there may be noticeable differences in performance depending on the device.
lyrics<-get_discography_lyrics(artist_id = '343657') #Leiva names(lyrics) #> [1] "92" #> [2] "Afuera en la ciudad" #> [3] "A Ti Te Ocurre Algo" #> [4] "Aunque sea un rato" #> [5] "Breaking Bad" #> [6] "Cerca" #> [7] "Ciencia ficción" #> [8] "Como Si Fueras a Morir Mañana" #> [9] "Costa de Oaxaca" #> [10] "Dejándose Caer" #> [11] "Del hueso una flor" #> [12] "El Caso de la Rubia Platino" #> [13] "Electricidad" #> [14] "El Gigante Big Fish" #> [15] "El Último Incendio" #> [16] "Eme" #> [17] "En el Espacio" #> [18] "Expertos" #> [19] "Extasis" #> [20] "Francesita" #> [21] "Godzilla (feat. Bunbury & Ximena Sariñana)" #> [22] "Guerra Mundial" #> [23] "Hermosa taquicardia" #> [24] "Hoy no me encuentro" #> [25] "Hoy Tus Ojos" #> [26] "La Llamada" #> [27] "La Lluvia en los Zapatos" #> [28] "Las cuentas" #> [29] "Lobos" #> [30] "Los cantantes" #> [31] "Maniobras Suicidas" #> [32] "Medicina" #> [33] "Miedo" #> [34] "Mi mejor versión" #> [35] "Mi Pequeño Chernóbil" #> [36] "Mirada perdida" #> [37] "Monstruos" #> [38] "No Te Preocupes por Mí" #> [39] "Nuclear" #> [40] "Nunca nadie" #> [41] "Palermo No Es Hollywood" #> [42] "Palomas" #> [43] "Penaltis" #> [44] "Polvora" #> [45] "Que nunca mueran los cantantes" #> [46] "San Sebastian - Madrid" #> [47] "Sincericidio" #> [48] "Sixteen" #> [49] "Superpoderes" #> [50] "Telediario" #> [51] "Terriblemente Cruel" #> [52] "Todo Lo Que Tu Quieras" #> [53] "Vertigo" #> [54] "Vis a vis"
lyrics$`San Sebastian - Madrid` %>% kable()
x |
---|
Letra de “San Sebastian - Madrid” Atravesando las nubes Tu decidiendo por mi A ver si no me destruye Lo que quería decir Tu ibas cogiendo las olas Yo andaba loco por ti Cuando giraron las cosas San Sebastián-Madrid Vuelve a mi Vuele despacio y lento Hacia aquí A veces saco los dientes A veces quiero dejarte ir A veces vamos de frente A veces vuelvo a confíar en ti A veces no me convences Y el miedo a pensarlo Vuelve a alejarme de ti Yo me tumbaba en las vías Tu conseguías dormir Por una vez en la vida Me recordaste a mí Tu ibas abriendo las alas Yo me intentaba rendir Otro verano se acaba San Sebastián-Madrid Vuelve a mi Vuele despacio y lento Hacia aquí A veces saco los dientes A veces quiero dejarte ir A veces vamos de frente A veces vuelvo a confíar en ti A veces no me comprendes Y el miedo a pensarlo Vuelve a alejarme de ti (pa, pa pa pa, papa, pa) A veces saco los dientes A veces quiero dejarte ir A veces vamos de frente A veces vuelvo a confiar en mi A veces no me convences Y el miedo a pensarlo Vuelve a alejarme de ti |
If you encounter a bug, please file an issue with a minimal reproducible example on Issues. You can also make an inquiry if you wish.