Defines functions search_genius_artist

Documented in search_genius_artist

#' @title Search Artist
#' @name search_genius_artist
#' @description This function searches 'genius' artists by name
#' @author Alberto AlmuiƱa
#' @param artist_name String of artist name
#' @param access_token Genius Web API token. Defaults to Sys.getenv('GENIUS_API_TOKEN').
#' @return
#' Returns a data frame with the artist's information
#' @details All Genius API endpoints require an artist or song ID. The `search_` functions in this package
#' try to search for the desired artists/songs to obtain their Genius ID and to use them later.
#' @export
#' @examples
#' \dontrun{
#' search_genius_artist('Arctic Monkeys')
#' }

search_genius_artist<-function(artist_name, access_token = Sys.getenv('GENIUS_API_TOKEN')){

  res<-RETRY('GET', url = 'https://api.genius.com/search',
             query = list(q=artist_name,
                          per_page = 50,
                          access_token= access_token),
             quiet = TRUE) %>% content

  if(res$meta$status != 200){stop(str_glue('Information not found for artist_name: {artist_name}'))}


  result<-purrr::map_df(seq(length(info1)), function(this_artist){



      id = info$id,
      name = info$name,
      url = info$url,
      image_url = info$image_url,
      header_image_url = info$header_image_url,
      is_verified = info$is_verified,
      is_meme_verified = info$is_meme_verified

  }) %>% distinct()



Try the rgenius package in your browser

Any scripts or data that you put into this service are public.

rgenius documentation built on July 1, 2020, 10:28 p.m.