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

5 comments:

t3rmin4t0r said...

Next time, make clean before you tar up a package like this :)

Also, the right way to pull files in pidgin would be purple_util_fetch_url_request, so that it'll work with the proxies I've got set.

Puthali said...

@t3rmin4t0r: i thought i did do a make clean :) 'n yea didn't know abt tht api, will use tht next time :)

Anki said...

hey puthali..good stuff!! its nice to also upload the patch indicating the exact changes that you made to a particular existing source code..helps folks in reviewing and enabling use with more later versions of the tarball ;-)

Nik said...

Have a look here:

http://pidgin-lastfm.naturalnet.de

Musictracker has some serious issues that prevent me from using it ...

ganool said...

what a cool blog here..
very simple but with good post..