The purpose of this package is to provide an efficient method of downloading song lyrics using the ‘genius’ API.

Installation

You can install the development version of rgenius from Github with:

remotes::install_github('AlbertoAlmuinha/rgenius')

Autenthication

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')

Usage

Search Functions

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://genius.com/artists/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

https://genius.com/Logic-paradise-lyrics

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

https://genius.com/Coldplay-paradise-lyrics

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


Songs Information

Media

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

http://www.youtube.com/watch?v=1G4isv_Fylg

55882

spotify

audio

https://open.spotify.com/track/6nek1Nin9q48AVZcWs9e9D

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.


Lyrics

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?


Lyrics Discography

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


Getting Help

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.