knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

library(xml2)
library(knitr)

rgenius

CRAN status Lifecycle: maturing Travis build status Total Downloads

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.

Installation

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

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


You can also get the ID of a song as follows:

search_genius_song(song_name = 'Paradise') %>% tail(3) %>% kable()


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

Among the information obtained, we find the media that host this song and a direct link.


Producers

Information from the song's music producers can be obtained as follows:

get_song_producer_artist(song_id = '55882') %>% kable()


Related Songs

You can also search for songs related to the original:

get_song_relationship(song_id = '55882') %>% head(5) %>% kable()


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


get_genius_song_lyrics(song_id = '154314', output = 'text') %>% kable()


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', cores = 2) #Leiva

names(lyrics)
lyrics$`San Sebastian - Madrid` %>% kable()


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.



AlbertoAlmuinha/rgenius documentation built on May 18, 2020, 3:19 p.m.