DIY iPod > Last.fm Uploader
Mon Jul 30, 2007 · 327 words

last.fm is a really cool site. I've found lots of interesting bands and information from there. Their software is unfortunately pretty crummy. The first time I tried it, the official client mysteriously crashed on me on launch for almost 6 months straight. It's also not very Mac-like (Cmd-S for Stop, hello?). iScrobbler, especially the 1.5.x series, is getting better, but doesn't support iPods.

The official last.fm client tries to upload track data from an iPod but at least for me, fails miserably. When iPod support is enabled, two (!) copies of the conduit spring open and then both crash when I go through the wizard…

None of that really matters because last.fm has an approachable API backend which any member can use to both poll and upload track data. All you need is to get the track info from iTunes and use any HTTP client to upload it to the server.

I simply started off by creating a smart playlist containing the tracks I've listened to during the past day on my iPod and limiting them to 50 (last.fm batch submission limit). I then used AppleScript through osascript, combined with curl (-d). This proved surprisingly messy. Since pure AppleScript sometimes still makes me want to pick up smoking again, I ended up using Ruby and RubyOSA

So here it is, my first ever Ruby script. Still (very) far from perfect but somehow does it's thing. The last.fm backend can be very unreliable so without proper caching and redundancy, the usefullness of this will remain very limited. Just connect your iPod, make sure you have the Recently Played playlist set up and run it with

ipod2last.fm.rb myusername mypass

All of this made me come to a pretty neat idea. Why not create a PHP extension that would expose Apple Events to PHP? Like RubyOSA, but for PHP. Combining the most popular web programming language with the rich possibilities of AppleScript would surely enable for some really cool apps!


back · essays · credits ·