Scheduling things can be surprisingly difficult for a graduate student - you need to keep track of classes, seminars and various other meetings. Over the years, I’ve come to rely on Google Calendar to help me organize myself from day to day. I keep all my appointments there - having them all in one place makes them more difficult to miss, and makes scheduling future appointments a lot easier. Unfortunately, not everyone uses Google Calendar: for example, my lab uses an antique version of xoops; my gym uses supersaas.com. This means I need to keep track of three calendars when making a new appointment:
I have enough trouble keeping up with one calendar, let alone three. Fortunately, it’s fairly easy to import calendar entries into Google calendar, even if the source of the import doesn’t cooperate explicitly.
For xoops, I wrote a Python script that:
Python makes it all really easy. The requests makes fetching remote content a one-liner (I used urllib, but that was before I discovered requests). Regular expressions can make parsing structured text very simple (although given that it’s HTML, using something like lxml would have been even better). Working with dates and times is also easy thanks to the datetime module. Finally, Google supports a Python API that allows you to programmatically update your calendar (among many other things). The 2.0 API is somewhat dated; Google released Python client libraries for the newer 3.0 API after I wrote the script. So that’s all the hard work out of the way - all you need to do is to glue the components together. Here’s the source. I run it as part of a cron job on my Linode periodically.
For supersaas, the deal is pretty similar, except I got a little lazy and didn’t investigate crawling the calendar remotely. Their calendar sends notifications of new appointments via email, so I wrote a quick-and-dirty script that hits my inbox once every couple of hours and processes new notifications using some regular expressions. The component that pushes the entries to Google calendar is virtually identical. Here’s the source - like I said, it’s pretty quick-and-dirty, but works well enough.