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.


mistypeppers
3 October 2008 @ 3:33 am
cool
Plabebob
25 November 2008 @ 7:34 am
Awesome thanks! Works really well & better than just a top albums gadget cause I wanted one that updates.
radyo dinle
3 January 2009 @ 4:01 am
Thanks i will use it in my radio website
Wendy
28 January 2009 @ 8:00 am
I dunno what I’m doing wrong, halp!
http://theweirdone.com/test (I have a different lastfm section on there too)
Have put php here
http://theweirdone.com/bits/lastfm.php
and I’ve used the include on my test page. It’s just not showing up? The lastfm.php itself throws up some errors when you go to the url
Tom Henderson
29 January 2009 @ 11:31 am
I think you need to create the cache directory on your server and set the permissions on it so the script can write it’s cache files to it. Then it should work.
nick
2 February 2009 @ 8:54 am
awesome man, thanks! finally something usable…
besides ‘weeklyalbumchart’ what other options do i have?
mk
11 May 2009 @ 8:54 am
Hi,
Very nice!
DO you know if there’s a way to have the artist name + album name in Text instead of the picture?
Thanks,
mk