ze goggles

Generating dynamic playlists with spotify-api

It's been a while since I released spotify-api, a homegrown implementation of a restful API to the Spotify music service. Now that the API is getting to a usable state I decided to build some applications on top of it.

What music do your friends love?

My goal was to automatically create some Spotify playlists with interesting or personalised content. On Last.fm there is a concept of loved tracks, where users can tag songs they like. So, if you share a similar music taste with your friends on last.fm you can easily create a good playlist by taking all the recently loved tracks from your friends and convert them into a Spotify playlist.

last.fm loved tracks

What you get is a "socially filtered" playlist, hopefully with some good music friends would recommend to you anyway. Another option would be to take recently loved tracks by your last.fm neighbours, but that relies more on algorithms used by Last.fm than trust (but which could still produce interesting results).

Here's the code for code for generating those playlists: lastfm2spotify_loved_tracks, you'll need a Last.fm API key as well as a premium Spotify account to use it.

What music do people listen to in other cities?

citysounds.fm

I really like the citysounds.fm mashup, which uses music and data from soundcloud to give you an idea what styles of music get produced in different cities across the world.

Last.fm have recently added some functionality to their API which let you grab music charts by location (New Geo Services: Metro Charts).

The difference here is that citysounds.fm provides you with music produced in different cities, whereas the Last.fm data is music consumed in those cities.

Here are some Spotify playlists produced from this data:

I used the getMetroUniqueTrackChart API method to obtain the tracks, which is meant to return tracks uniquely popular in a city. This kind of works, although there are still some tracks present in most of the playlists (The xx seem to be everywhere!) it generates some unique and local tracks. The Berlin playlist has a good share of techno (Paul Kalkbrenner), Paris is quite heavy on French productions such Air and Vitalic, and Auckland has a lot of Ladyhawke and Fat Freddy's Drop, both hailing from Wellington.

The Rome and Barcelona playlists both have quite a few Italian and Spanish songs in them, in fact the Rome playlist is mostly Italian. Oslo has a lot of Kings of Convenience and Röyksopp, and so on. I'm not sure how Last.fm generate this data and how representative it is for a given city, it probably depends on the number of users in a location.

If you want to have a play yourself, the code to generate these playlists is in the spotify-api repo (lastfm2spotify_metrochart). You might experience occasional timeouts using the API, it's not rock solid yet. Also make sure to check the Spotify service status to verify that all services are working as expected.

recently on twitter

currently reading