knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" ) library(xml2) library(knitr)
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 rgenius
from CRAN:
install.packages('rgenius')
Or 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()
You can also get the ID of a song as follows:
search_genius_song(song_name = 'Paradise') %>% tail(3) %>% kable()
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()
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()
You can also search for songs related to the original:
get_song_relationship(song_id = '55882') %>% head(5) %>% kable()
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()
get_genius_song_lyrics(song_id = '154314', output = 'text') %>% kable()
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)
lyrics$`San Sebastian - Madrid` %>% kable()
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.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.