A few people have asked how I got the list of songs on the right from Audioscrobbler (now last.fm), so I figured I’d put the script up, explain it once, and save myself a few minutes.
First, you need the XML from Audioscrobbler. I have a cron job set up to download mine every 5 minutes. I keep the XML locally, just in case Audioscrobbler is slow; I don’t want my site to consequently be slow. Here’s what my cron entry looks like. You will have to modify the paths accordingly for your server. Also, replace ‘USERNAME’ with your Audioscrobbler username.
*/5 * * * * /usr/bin/wget -O /path/to/your/recent.xml “http://ws.audioscrobbler.com/rdf/history/USERNAME” > /dev/null 2>&1
Next, you should grab the ParseXML class (linked below) that I got .. somewhere .. I don’t remember where, and there’s no information in the file. It will parse the XML that you will get from Audioscrobbler. While you’re saving files, pull the PHP file down that uses this class to parse the XML. That file will need to be edited to account for the path to the XML file, as well as your audioscrobbler username.
parsexml.php (right-click, save as)
listening.php (right-click, save as)
Put both of these in the same directory on your server. You can either include the php code from listening.php in your files, or run it by itself. Feel free to edit the HTML that it outputs .. it was what I needed for mine, but yours will most likely require a different formatting.
This was written pretty quickly, so if you have any problems or questions, comment here and I’ll try to clarify as soon as I can.
Hmm, I have (had) some free time, tonight.
Catch up on some work? Um, nah. (hah)
Work on some websites for fun? Nah.
Work on some websites for money? Nah.
Watch a movie? Nah. No more.
Learn a new song? Nah.
Write a new song? Nah. Can’t.
Go out and take pictures? Nah.
Stay in and take pictures? Nah.
Look at houses online? Nah. No more.
Surf Flickr? Nah. No more.
Clean up? Nah. It’s not too bad in here.
Listen to music? Nah. No more.
Sleep? Probably, soon.
I want to do most of the above, but when I start to (or attempt to start to) do them, I have this strong urge to not be doing them, almost instantly after I start them. You know something’s out of whack when relatively easy money doesn’t even motivate you. I need to reboot myself, somehow. Blah? Nah.
Jeff asked if I could share the code to post to LJ, and since I borrowed it from somewhere else, I figured it wasn’t a problem. So here you have it: http://www.pubarso.com/misc/ljwp/. It should work with DeadJournal, too. I’ve read they use the same xml-rpc interface. Someone try it out and let me know. All instructions are included in the readme.txt file.
This is for WordPress 1.3. I haven’t tried it in 1.5. You may need to modify it to work properly.
