Spotify Artists Discography

shuggie discography

Following on from my last post I’ve added a few more functions to my SpotifyAPI package.

It now includes getArtistsAlbums which takes the output from a getArtists search and finds the albums by that artist and outputs a data.frame. This can be followed up by a getAlbumsTracks which will find all the tracks from those albums and create a data.frame. Finally I’ve added visDiscography. This uses both those functions along with the get artist function to create an interactive visualisation of an artists discography.

The biggest challenge here was creating the json file to insert into the d3. It requires a nested json, so I had to write a function that works back through the data.frame nesting at each level. The function can be found in this gist.

Then it was a case of adjusting the original d3 to suit my purposes. I added in the function to the javascript to link to the music samples. Replaced the node circle with a click play button image and used the hover function in the css to highlight the buttons.

The final output shows all an artists albums and the tracks on those albums. You can click on a track to listen to a short sample from the track. You may need to adjust the height in the html file if you have lots/not many albums and tracks.

Here’s the code for Shuggie Otis:

out<-visDiscography(artist="Shuggie Otis", output_file="Shuggie Disco.html")

Here's the output and have a listen to some Shuggie:

Leave a Reply

Your email address will not be published. Required fields are marked *