Sunday, May 07, 2006

Rhapsody and Google Calendar Mashup

At Mind Camp 2.0, Leo and Katie (from Rhapsody.com) and I started work on a mashup. We wanted to combine Google Calendar with Rhapsody. Instead of waking up to an annoying alarm-clock-radio, it would be nice to wake up to your favorite music.
How to get the data from Google Calendar:
This was easy. Google Calendar can output an RSS feed of your calendar. So, you just give our mashup the URL of your gCal RSS... and we can go from there.
How to play music via Rhapsody:
This was easy. Leo and Katie know all about Rhapsody (duh)... so I didn't even have to research how to do this. We use Rhapsody's Simple.js API... and it is definitely simple.
How to get Album information from Rhapsody
:
Rhapsody outputs an RSS file for every album. So, when the time comes to play... the mashup grabs the RSS, parses it, and builds an array to send to simple.js.
Example: http://www.rhapsody.com/riseagainst/theunravelingreissue/tracks.rss

We used the Prototype javascript framework for the PeriodicalEvent timers. One timer fires off every 2 seconds to see if its time to play the music. One timer fires off every 5 minutes to get an updated RSS file from your gCal. We also used the Prototype class because it has super-simple AJAX methods in it. So, we were able to grab the RSS feeds asynchronously.

Because it is next to impossible to remember the URL for your gCal RSS feed, you only have to enter it once. Then I squirrel that away into a cookie. The mashup detects if the cookie is there, and if it is... it just does its thing. If the cookie isn't there, the mashup doesn't do anything until you input your RSS.

unfortunately, I don't know javascript all that well... so the mashup doesn't work in Internet Explorer. It works in Mozilla and Firefox though.

I almost forgot to give you the link to the site! here you go:
http://borrowr.com/~adam/mashup/
There is some basic documentation on how to use the mashup available on the site.

Please leave your comments and concerns here if you have any. Feedback is always cool.

(PS: Another funny Blogger Spellchecker word missing from their dictionary: Google).

3 comments:

katie said...

Way to go Adam! It's great to wake up to music. ;) Thanks again!

Julian said...

Hi -- borrowr.com is down?

cheers,
J

Adam said...

I know. We're working on getting it back up. We had to pull the server out of the data center because it was crashing, and we couldn't diagnose it remotely. Hopefully it'll be back soon.