Last.fm + Drupal goodness

I signed up to Last.fm just the other day, meanwhile the world has been listening to tunes pumped out by their incredible service since the turn of the century! As I manually typed all the artists from my iPhone into my favorites listing I began to explore just how accessible their service was.

Yup just as I guessed there is a full blown API, mobile plug-ins including the iPhone, and a tonn of ways on your computer to listen to music.

So I was interested in two things, firstly the ability to listen to anything I pleased on my iPhone, but also their web API as to pull in some statistics recently listened to tracks into my new blog.

This blog is built in Drupal 6, and proudly so. However it's sometimes very hard to find reliable and well coded modules that do exactly what you intend or expect them to do. So i decided to take a class written by Jeroen Smeets and dropped it into a new hand crafted module.

Of course with everything there is tweaking needed for it to fit comfortably into Drupal's comprehensive framework. Firstly the class outputted simple html so I moved this out into theme functions, as all output should be placed. Secondly i moved all the configuration variables out into a customizable administration page. Then came refactoring some of the caching functionality to use Drupal's file directory, and ensuring the code generally ran well.

The result is as you can see at the bottom of the site. A lovely list of recently listened to tracks with the album artwork. So well done Mr Smeets, your hard work saved me literally hours of work and was able to port it to a Drupal 6 module in a matter of an hour. I look forward to getting the 1.4 version of the class, as I sure as hell ain't porting it from Wordpress!

Recommended reading

Design by Jon