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
This plugin works with both the loved tracks feed, and the recent tracks feed. It might work with others, but I haven’t tested it…
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
Cool~ Thankyou for the Plugin ^u^
sweet plugin, thank you.
would you have any pointer to something similar for wordpress by any chance. (not a dab hand in php at all…) struggling on this one:http://www.cklavery.net/lifestream/items/site/cklavery.wordpress.com
What do you want it to do? Create a WordPress blog post for every song?
Very cool idea. I’m just playing around with Sweetcron, so I still haven’t fully worked out how to use and abuse this, but it looks great
Nice plugin Chris – my only gripe with Sweetcron is that it duplicates data. I’ve been wanting to come up with something similar to Sweetcron but let it pull in data live as and when it needs it.
Of course this would be very difficult and could be slow for users as it would need to abuse AJAX so much.
Hi Phunky – I’ve never come across the duplication thing, what does it duplicate?
You’re such an ajax junkie 😛
thank you very much for this!
exactly what I was looking for. thanks.
This is exactly what I want, but unfortunately I can’t get it to work at all.
Can you please confirm that this still works, so I know if it’s just me.
The problem was a database issue. I cleared the items table and reloaded, and now it works.
But the album art terms seems to be mixed up. “small” gives a large image, and “large” gives a small image.
I’m testing this out on my local install of SweetCron, and it’s kinda working, kinda not.
I’ve got it set up to grab the artist and title of the track separately and using the urls to generate the link to the relevant page. Its working, except that it returns no data for every second track. very curious. Any ideas?
Hey there – is this plugin still supported? I’ve mostly got it working… I think? I have errors on feed imports though so I don’t know…
Not really. I sacked off using Sweetcron when it’s creator moved to Posterous!
I don’t know if the sweetcron project has been taken over by anyone, but it’s possible they’ve made changes under the hood that could affect the plugin. I’m not sure without digging through the code, sorry. 🙁