Last.fm Charts
6 July 2008

This is a fun little script I wrote up that reads your weekly top albums chart from Last.fm, gets the cover art for each album, then displays the top albums on your blog. Scroll to the bottom of the page to see how it looks. Yes, there are Wordpress plugins that do this already, but I always think it’s a bit more fun to try to roll my own. Most of other scripts tend to use your recent tracks feed as well, which doesn’t work well for me as I tend to listen through albums so my feed only ever shows a couple of albums. The data I’m using comes from Audioscrobbler’s web services, and there a loads more feeds available for those wanting to customize the script.
The script needs to be included manually in your blog template, so should work fine in any blog software running on a server with php 5 or higher. If you are comfortable with php you should find it easy to customize the output to suit your blog design.
To use, download the script, upload to your server and use include 'path/to/lastfm.php'; to add it to your template. Then you’ll need to create a cache folder somewhere on your server and change it’s permissions to 766. (The script uses some simple caching to avoid over use of the xml feeds, but it should probably be caching the images as well.) Then edit the top of the lastfm.php file to customize your settings. You’ll also need a blank album image to use when something goes wrong.
The script outputs pretty simple html that should be easy enough to style with just css.


