Dave Beckett's blog

RSS to iCalendar

2006-05-10 05:21

I made a quick hack and after showing it to a few people at the Jena User Conference 2006 in Bristol, it seems it might be worth showing to people. I had this flash of inspiration\^wthe obvious: RSS is a format that is a syndication feed of items with (date, time, description) which sounds remarkably similar to a calendar file such as iCalendar ICS files produced and consumed by calendar programs such as Apple's iCal. So I made a program that uses Raptor's rss-tag-soup parser to read any RSS/Atom feed into an RDF graph (*), query it with SPARQL to grab the entries and then output it in the iCalendar format. Most of my time was spent dealing with the baroque \-escaping of the result format, and trying to get the RSS dates to work; even with the help raptor gives using curl's curl_parsedate to uplift from RSS date junk.

So the result is: rss2ical.c and here's PlanetRDF's feed as a calendar: http://planetrdf.com/index.ics which works in at least the two programs I tested: Apple iCal and Google Calendar.

(Of course this feed is proper RSS 1.0/RDF so the rss-tag-soup parser is not necessary; I could use raptor's guess parser to do the right thing.)

I tried it on some other feeds in the wild too and it mostly worked but it looks like there are some other bugs to shake out. I'm interested to what people think of this as an alternative interface to the River of News format. It allows you to skim a bit easier in your calendar and to see when news items arrived. I'm not sure if I'll run it as a PlanetRDF service yet.

(*) This means with a slight modification, it could do an aggregated calendar if I loaded in multiple feeds.