charlie86 / spotifyr

R wrapper for Spotify's Web API
http://www.rcharlie.com/spotifyr
Other
367 stars 66 forks source link

Add genres array to get_track output #193

Open erikgregorywebb opened 1 year ago

erikgregorywebb commented 1 year ago

The Spotify Get Track endpoint includes a genres array in the response:

genres (array of strings)
A list of the genres the artist is associated with. If not yet classified, the array is empty.

Ideally, the array would be included in the output of the get_track function of the spotifyr package. As far as I can tell (sample output below), it is currently not.

$ album            :List of 13
  ..$ album_type            : chr "album"
  ..$ artists               :'data.frame':  1 obs. of  6 variables:
  .. ..$ href                 : chr "https://api.spotify.com/v1/artists/2R21vXR83lH98kGeO99Y66"
  .. ..$ id                   : chr "2R21vXR83lH98kGeO99Y66"
  .. ..$ name                 : chr "Anuel AA"
  .. ..$ type                 : chr "artist"
  .. ..$ uri                  : chr "spotify:artist:2R21vXR83lH98kGeO99Y66"
  .. ..$ external_urls.spotify: chr "https://open.spotify.com/artist/2R21vXR83lH98kGeO99Y66"
  ..$ available_markets     : chr [1:184] "AD" "AE" "AG" "AL" ...
  ..$ external_urls         :List of 1
  .. ..$ spotify: chr "https://open.spotify.com/album/7JtT7OyWM8BnIS5FXXPMKg"
  ..$ href                  : chr "https://api.spotify.com/v1/albums/7JtT7OyWM8BnIS5FXXPMKg"
  ..$ id                    : chr "7JtT7OyWM8BnIS5FXXPMKg"
  ..$ images                :'data.frame':  3 obs. of  3 variables:
  .. ..$ height: int [1:3] 640 300 64
  .. ..$ url   : chr [1:3] "https://i.scdn.co/image/ab67616d0000b2733cb695bfc1246bdf66161fce" "https://i.scdn.co/image/ab67616d00001e023cb695bfc1246bdf66161fce" "https://i.scdn.co/image/ab67616d000048513cb695bfc1246bdf66161fce"
  .. ..$ width : int [1:3] 640 300 64
  ..$ name                  : chr "Emmanuel"
  ..$ release_date          : chr "2020-05-29"
  ..$ release_date_precision: chr "day"
  ..$ total_tracks          : int 22
  ..$ type                  : chr "album"
  ..$ uri                   : chr "spotify:album:7JtT7OyWM8BnIS5FXXPMKg"
 $ artists          :'data.frame':  2 obs. of  6 variables:
  ..$ href                 : chr [1:2] "https://api.spotify.com/v1/artists/2R21vXR83lH98kGeO99Y66" "https://api.spotify.com/v1/artists/4q3ewBCX7sLwd24euuV69X"
  ..$ id                   : chr [1:2] "2R21vXR83lH98kGeO99Y66" "4q3ewBCX7sLwd24euuV69X"
  ..$ name                 : chr [1:2] "Anuel AA" "Bad Bunny"
  ..$ type                 : chr [1:2] "artist" "artist"
  ..$ uri                  : chr [1:2] "spotify:artist:2R21vXR83lH98kGeO99Y66" "spotify:artist:4q3ewBCX7sLwd24euuV69X"
  ..$ external_urls.spotify: chr [1:2] "https://open.spotify.com/artist/2R21vXR83lH98kGeO99Y66" "https://open.spotify.com/artist/4q3ewBCX7sLwd24euuV69X"
 $ available_markets: chr [1:184] "AD" "AE" "AG" "AL" ...
 $ disc_number      : int 1
 $ duration_ms      : int 246000
 $ explicit         : logi TRUE
 $ external_ids     :List of 1
  ..$ isrc: chr "QM4TX2084345"
 $ external_urls    :List of 1
  ..$ spotify: chr "https://open.spotify.com/track/06s3QtMJVXw1AJX3UfvZG1"
 $ href             : chr "https://api.spotify.com/v1/tracks/06s3QtMJVXw1AJX3UfvZG1"
 $ id               : chr "06s3QtMJVXw1AJX3UfvZG1"
 $ is_local         : logi FALSE
 $ name             : chr "Hasta Que Dios Diga"
 $ popularity       : int 77
 $ preview_url      : chr "https://p.scdn.co/mp3-preview/98b4dda8deea74c988ebce56461a86b3683c334c?cid=ea41f77eb37f4e7ea9f21424449ad327"
 $ track_number     : int 5
 $ type             : chr "track"
 $ uri              : chr "spotify:track:06s3QtMJVXw1AJX3UfvZG1"
pitkant commented 1 year ago

spotifyr's get_track function does not seem to do any other processing to the JSON output from API than run it through fromJSON function. It would seem that the information is not returned by the API at all despite it being listed in the documentation.

Spotify for Developer Console does not return genres data either.