UPenn Calendar Fixer-upper

Penn has a neat university-wide event calendar which is useful for keeping track of events in my own and other departments.  Even better, the Penn calendar has a fancy export web service that lets you export filtered information (such as events for a specific department, or for a specific date range) to a variety of different formats (such as XML or iCal).  I like the iCal format because I can import the iCal URL into Google Calendar and everything shows up in one place automatically. For reference, the (underdocumented) magic incantation to get an iCal feed of Electrical & Systems Engineering events is http://www.upenn.edu/calendar-export/?school=4&owner=115&showndays=200&type=ical2.

A few notes about this URL: the ESE department has owner id 115.  CIS, my department, has owner id 15.  You can find the owner id for a given department by finding some event scheduled by that department on the calendar, and then clicking the “Month listing of XYZ events” link, and the resulting URL will have the owner id in it.  Also, this feed only shows events in the next 200 days, so events from the past will disappear.  This is tolerable since I only live for the future anyway!

While everything seemed great at this point, it wasn’t until I was about to set off for an ESE lecture that I realized the shortcoming of this approach. While the title and time of each event show up correctly, the location information is often truncated to show only the building the event is in.  While the buildings in Penn Engineering are not terribly large, knowing the room for each event is still pretty essential.

Through some exploration I discovered that the XML feed of events has two elements describing the location of an event: <location> and <room>. The LOCATION field of an iCal event contains only the <location> information, which is typically a building name.  If only there were a way to augment the iCal feed with this little extra bit of information!  I emailed the Penn Calendar folks about this a few weeks back but nothing seems to have changed.

Fortunately, this is the Internet: if I am unhappy with someone’s web service I can just build my own wrapper to fix things. I had been meaning to play around with Google App Engine for awhile and this was the perfect excuse.  I built a web service that, given a query string, will use that query to get a feed of events from the Penn Calendar export service in both iCal and XML formats. For each iCal event, it looks up the event in the XML feed and adds the extra room information to the iCal event. Then, it pushes out the augmented iCal feed as a response. This web service is running at http://penncalfix.appspot.com/penncalfixer.  Thus, you can subscribe to a more-useful iCal feed of ESE department events using the following URL: http://penncalfix.appspot.com/penncalfixer?school=4&owner=115&showndays=200. Note that the &type=ical2 part is elided as the service automatically delivers an iCal feed.

The code for the web service is also online at https://github.com/devietti/PennCalFixer. It’s written in Java with ical4j to do the iCal parsing and jdom for the XML parsing. Hopefully this makes the Penn Calendar export service useful for others as well!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s