The purpose of this package is to provide an efficient method of downloading song lyrics using the ‘genius’ API. For more information visit the pkgdown website.
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
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
55882
Paradise
Paradise by Coldplay
8351
Coldplay
complete
30046
2843318
The Other Side of Paradise
The Other Side of Paradise by Glass Animals
87048
Glass Animals
complete
3642337
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
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
55882
112992
Daniel Green
55882
29974
Rik Simpson
55882
29972
Brian Eno
You can also search for songs related to the original:
get_song_relationship(song_id = '55882') %>% head(5) %>% kable()
type
id
title
url
full\_title
img\_url
lyrics\_state
artist\_id
artist\_name
artist\_url
sampled\_in
2441408
Wagner is a Cold Player
Wagner is a Cold Player by Wagner: R\&B Superstar
complete
650686
Wagner: R\&B Superstar
covered\_by
516475
Paradise
Paradise by Craig Owens
complete
24658
Craig Owens
remixed\_by
423218
New World
New World by NetNobody
complete
1167521
NetNobody
remixed\_by
1818754
Paradise (Tiësto Remix)
Paradise (Tiësto Remix) by Coldplay (Ft. Tiësto)
complete
8351
Coldplay
remixed\_by
2336572
Death of Me (Paradise Remix)
Death of Me (Paradise Remix) by Andy Mineo (Ft. Coldplay)
complete
14035
Andy Mineo
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', cores = 2) #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.
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.