This is the Unix philosophy: Write programs that do one thing and do it well. —— Douglas McIlroy

I was dissatisfied with the state of API integration in Ruby, and I decided to do something about it.

The API has a whole load of interesting functionality, but the most useful one is scrobbling: pushing information about the music you’re listening to to The point of doing this is that you can:

  1. go back and work out what that song was that you liked; and
  2. make a note of the tracks that you like; and
  3. use statistics about you listening habits to recommend more music, or just to pick out a playlist for your portable player.

I’ve been listening to a fair bit of internet radio recently, and I’m hearing a lot of new (to me) music that I like. I’ve written some code to help me keep track (for Shoutcast servers, for example). One problem that I found was that there doesn’t seem to be any simple, working implementation of the basic scrobbling protocol for Ruby. The available libraries, like scrobbler-ng, seem to do everything but. I mean, scrobbler-ng claims to do it, but I couldn’t get it to work at all, and the code behind the scenes doesn’t seem to be hooked up to support basic scrobbling.

So I asked James what he’d used for his vinyl/Shazam/ hack, and he pointed me at some rough-and-ready code that (almost!) did the job.

I’ve taken it and tidied it up—well, rewritten it, really: I wrote some high level tests around the existing code, refactored it, then made the tests a bit more granular, then refactored it some more. And so, I give you SimpleScrobbler:

Scrobble tracks to without wanting to gnaw your own arm off.

It’s pretty easy to use. It doesn’t do much. And it actually works.