After falling for Sweetcron and setting up my own online lifestream, I found that using Last.fm’s RSS feed wasn’t giving me enough data – all I was able to work with was the track title (artist – title as a single string) and a link to the last.fm page. This seemed like a bit of a waste, and meant that if I ever wanted to expand my Sweetcron theme in the future, I’d be stuck with this limited set of data to use.
The Last.fm for Sweetcron plugin is a simple tool for populating the feed with a bit more useful information to play with. When enabled, it connects to the last.fm API as the feeds items are added to the database and grabs the extra info. When done, you can access the following data from within your
_activity_feed.php file using
$item->item_data['xxx'], replacing xxx with one of the terms below in bold:
- Title (track_title)
- Link to last.fm page (track_url)
- Song duration (duration)
- Number of listeners (listeners)
- Number of plays (playcount)
- Artist (artist)
- Link to artist’s last.fm page (artist_url)
- album title (album_title)
- Link to album’s last.fm page (album_url)
- Album art – small (image_url_small)
- Album art – medium (image_url_medium)
- Album art – large (image_url_large)
- Album art – 34×34 square (image_url_small_sq)
if this isn’t available, then the Artist art (same sizes)
- Wiki summary (wiki_summary)
- Wiki entry (wiki_entry)
- Wiki date (wiki_publish_date)
- Artist Bio summary (artist_bio_summary)
- Artist Bio entry (artist_bio_entry)
- Artist Bio date (artist_bio_publish_date)
So, to display the small image you’d use
By default, the script will try and grab the artist images if the track images aren’t available, and also the artists bio. As both of these require an extra API call, they may not be suitable if you’re running sweetcron on a slow web server. So I’ve added the option to switch each of these off individually – just look near the top of the plugin for
$getArtistImageIfNeeded and set them to false.
Any bugs or requests, let me know!
Put the file in the system/applications/plugins folder. Then add either your loved tracks or recent tracks RSS feed via your Sweetcron admin panel.
(Replace “chrismou” with your own last.fm username!)
0.9 – Release