Monday, March 03, 2008

Last.fm support for pidgin

This Sunday, played around with musictracker plugin for pidgin to make it support Last.fm. This was one niggling requirement for some time now. Most often I end up playing songs on a diff m/c than the one i run pidgin on, for variety of reasons - 'm playing songs off of my ipod through iTunes or 'm listening to last.fm through the browser/player itself or i would feel like listening on speakers which are connected to a different m/c or particular song/album is on that m/c...
Anyways as i googled for some plugin to meet my needs, came to know that many people apart from me, were also looking for one such 'n not finding one, decided to write one myself :) 'N as a good software programmer that i am, who knows the true potential of re-usability, realized its much "easier" to just extend musictracker plugin to support this feature than write one from scratch. ;)

And thats how my journey of realizing how much i had forgotten and re-learning started. To start with, it was almost a year since i had coded in 'c'. I had/have become this eclipse-spoon-fed Java developer. The only times i use 'vi', is occasionally when i open some files to do some basic editing. So here i was doing some pretty normal coding, nothing major, 'n i had such difficulty! I'd forgotten most of the 'vi' short-cuts apart from the basic 'yy' 'dd' 'n 'p'. So that took some re-learning.

Then there was the really paining autotools problem. I add a .c file to the source project, add the corresponding entry to Makefile.am, run ./configure and it doesn't compile! It ignores it completely as though there was no change. So spend couple of minutes checking, re-checking, getting totally worked up and it still doesn't work. Then from somewhere from my long-forgotten past-life came a thought - could it be that its the bootstrap problem? which basically means you run the aclocal,autoconf...etc commands 'n most importantly run 'libtoolize --force --copy'. And this is something which i hope gets corrected - "No one looks at ./configure output" So if there's no error in bold at the end of its run, user will assume that everything went fine. So whenever there's a mismatch between autoconf versions, its not a minor warning it should be major.

Anyways writing the last.fm code itself was pretty easy. It involved downloading the recent tracks file from audioscrobbler.net and getting the first entry from that. 'n yeah since audioscrobbler places restriction on how many times you can access it in a given time, had to do a check on the last modified time of the file, and download it only if its more than 30s. Ran into couple of issues using wget, so ended up using curl. Most of the other stuff was just interfacing with musictracker code - set the artist/track/status information, support to configure/store last.fm user name in preferences...

Remaining part is 've to put up this code somewhere, but then again, right now its only for linux 'n my guess is the people who want this are mostly on windows :) But modifying this to support windows should be easy and not take more than half an hour.

Thats it from me, will update this blog when i upload the plugin code somewhere.

>>Update
You can get the plugin here.

AdiĆ³s