Displaying Recently Played Tracks on Blogs
(I think this will work for any PHP blog like wordpress or b2evolution.)
So danah (via various posts) has got me really into Last.FM (and the associated Audioscrobbler plugin for iTunes). Last.Fm stores what people are actually listening to and allows you, like the original Napster did, to look at what other people are listening to.
Avast! The Audioscrobbler page for each user even publishes a feed (for example, my profile publishes this feed)!
So much am I enjoying Last.fm that I've even wrote a quick hack using magpieRSS and EdB's _magpierss.php to display the most recent tracks I've listened to on NQB's sidebar. Take a look over there to see what I'm listening to!
(I'll post my hack here tomorrow.)
UPDATE [2005-01-08 20:10]: Well, the side panel for my music wasn't updating. It turns out that you need to have a directory in the same folder as MagpieRSS for its cache (that is, it needs a place it can put stuff until the target feed has been updated). In short, you'll need to make a directory in this folder called cache with the proper permissions. The following (from the command-line) should do the trick:
mkdir cache chmod 755 cache
UPDATE [2005-01-09 09:50]: Alright, so here are the details of this sidebar audioscrobbler plugin hack based on [EdB]'s magpieRSS hack for b2evolution.
-
First, I listen to a lot of music... which means that I need the sidepanel to update itself more often than once an hour (the magpieRSS default). However, I also don't want to contribute to slamming the Audioscrobbler servers. MagpieRSS has a built-in cache feature which will check the time on the remote RDF/RSS/ATOM file and update the feed information only if this file is new and only after a minimum amount of time has passed (default is one hour).
You'll have to change EdB's hack to
_main.php(or your main PHP file) to redefine how often magpieRSS should check for updates to the field. Find this part of EdB's hack:< ?php
require_once( dirname(FILE).'/rss_fetch.inc' ); ?>and include a line that redefines the update time. Here, I use ten minutes (600 seconds):
< ?php
// define a time to check for RSS updates (in seconds) define('MAGPIE_CACHE_AGE', 600); require_once( dirname(FILE).'/rss_fetch.inc' ); ?> -
Next, I did some not-so-complicated but easy-to-fuck-up modification of EdB's
_magpierss.phpfile. So I've created a patch file_magpierss.php.patchthat you can apply to EdB's original file via the following command (make sure that the patch file is in the same directory as_magpierss.php):patch < _magpierss.php.patch
(Here are the two files (save as
.php):_magpierss.php.orig.txtand_magpierss.php.new.txt) What changes did I make? Well, a few things:-
I added a switch to not display item descriptions. For Audioscrobbler, the descriptions are the same as the titles, so this was redundant.
-
I added a switch that toggles shortening of titles. EdB had titles being shortened to 20 characters. I set this as a switch, the "unshortened" case shortens titles to 80 characters and the shortened case acts just like EdB's original. UPDATE: I actually had to increase this to two-hundred characters to accommodate long metadata for some classical music... like so:

-
I moved the site title to the end. I also hard-coded in "Joe's Audioscrobbler profile" as I can't change the dumb title that Audioscrobbler defaults to ("Audioscrobbler Music Profile: Joebeone"). You'll have to change this on your own. (Now that I think about it, it would be easy to pass in a site title from
_main.php. Screw it.)
-