Last.fm Recent Tracks RSS Consumption
|
We use iTunes to stream the music to the ‘Music Area’ (clever name) of the library. Last.fm, through their ‘Scrobbling’ software, provides access to an RSS feed of your latest tracks. Here’s my recent tracks feed. (Insert your last.fm user name in the url to get your own feed.) Once I installed the Last.fm application on the remote computer, our feed started working instantly. That was step 1. Step 2 was to get that feed published on a library page for easy advertising. Thankfully, jQuery has a plugin called jFeed. It does what you think – parses the RSS XML so you can output it as HTML – tada! That was relatively easy – they even provide a method to overcome cross-domain scripting woes. Step 2, Check! Wait! The timestamps are 6 hours off! What?! I don’t know why this happens but I’m not the only one. But I assume that the 6 hour difference is consistent and create a fix thusly:
Everything is now working fine and I could have left well enough alone, but I didn’t. The feed was displaying, the links back to last.fm were working, everything was special. However, I didn’t like the format of the datestamping: Enter timeago. Timeago is a jQuery plugin that does magic – it takes the loverly, aforementioned GMT timestamp and turns it into this: Obviously, this would have been easier for some to do in PHP. And it probably would have made more sense. Maybe someday I’ll do that. |
The 





Awesome work, Tom.
The only problem you’re going to run into is when you change between Daylight Saving time and Standard time. You’ll want to investigate the php option deeper because it has built in functions to accommodate that change.
Interesting. Does GMT not adjust for daylight savings? I wonder if there is a way I could test for that right now…