Creating an iCalendar from online timetables

I’m a member of my local swimming pool, Fleming Park. I’m trying to swim a lot at the moment (as it’s a big help for my back).

I don’t have a regular schedule, I just try and squeeze in time for a swim any time I can spare. This means I’ve not learned the pool’s schedule and frequently have to check their website to find when the pool is available.

I’m checking it so frequently that it’s one of my Most Visited thumbnails in Chrome.

This isn’t efficient, particularly as it’s normally on my phone making me switch between the browser and Calendar apps. It’d be quicker and easier if I had the timetable in my calendar alongside my appointments, so I could easily see when I’m free and the pool is open.

The leisure centre doesn’t provide a feed so I can subscribe and add their schedule to my calendar.

So I made my own.

dalelane.co.uk/…/swimflemingpark.ics

If you use the Fleming Park pool, import this in your Calendar app (or subscribe to it from Google Calendar) and the next week’s pool timetable will be kept up to date in your calendar.

I’ve done it with a quick bit of Python hacking. I download the HTML source for the next seven days’ timetables, and parse each of them using BeautifulSoup. I pick out the swimming session info, and generate an ics file for them using iCalendar for Python.

I’ve put it on my home media server, and set up a cron job to run it every twenty-four hours, with a shell script to upload it to dalelane.co.uk/files.

It’s a quick hack, so it’s specific to Fleming Park. Although, at first glance at another similar-looking local pool website, I think it’ll probably work on other DC Leisure Centre websites.

The source for the script is on github.

Tags: , ,

Comments are closed.