Github Github logo GitLab GitLab logo Twitter Twitter Mastodon Mastodon logo Wikipedia Wikipedia logo Stack Overflow Stack Overflow logo Stack Overflow Stack Overflow logo OpenStreetMap OpenStreetMap logo Creative Commons Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) Creative Commons BY-SA 3.0

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
loved tracks on last.fm

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
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.

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.