masthead
 
 

ioah2ical.py

Ice Oasis Adult Hockey Schedules to iCalendar

Latest Export March 27, 2008

Download iCalendar Schedules for Ice Oasis Adult Hockey

Save yourself the time of inputting your IOAH schedule(s)! The zip file below contains iCalendar schedules for each and every Ice Oasis league.Seeing as schedules seem to change frequently, you will also find a file in there that gives the export date.

IOAH_Schedules.zip

NOTE: Although I've checked the resulting ics files against my own schedule (and all appears fine), you still might want to run a quick double check to verify. I've imported the schedules into both iCal and Rainlendar and even Outlook 2007. No warranty implied. Use at own risk. Ice Oasis Schedules are known to change -- so double check Blah blah blah. Also note, the listing of all of the playoff games is no longer included.

Python Source & Readme

I have broken out the python source files and readme into a separate package (makes managing this all a bit easier). You can find those below.

File Package ioah2ical_source (includes ioah2ical.py, BeautifulSoup and Readme)

Current Revision

October 3, 2007

Written in:

Python 2.4 (works with 2.5 as well)

Dependencies

BeautifulSoup 3+


Purpose

Playing in 2 leages at Ice Oasis would typically mean a lot of manual entry of my game schedule into iCal (or Rainlendar on the PC). Since the Ice Oasis schedules are simply table formatted, they made for a nice project to scrape the html and then push the schedules into an iCalendar (.ics) file.

Features of ioah2ical.py

Created basic iCalendar class and iCalendarEvent class
Sure, I looked at other python implementations for iCalendar, but they all seemed heavy-handed or overly complicated for a simple web-scrape-to-ics-file. These are simple formatting classes. The iCalendar class exists to create the header and then append iCalendarEvent items. In the end, the class outputs .ics files for inclusion into all modern calendaring systems (of which Outlook is not a member). Feel free to port these classes to your own code.

*NEW* Created "zipDir()" function
Believe it or not, I had a tough time finding an example zipDir() function out there. I found some things that sort of did it (sort of), but nothing that really kept the directory structure intact. There are most definitely better ways of doing this. zipDir() is built into ioah2ical.py, but you can get the standalone function: zipDir.py

*NEW* Created basic i2iFrontEnd class
This enables the Autopliot mode. It's basically a storage/globals class for automating the login in process as well as the directory structure creation and whatnot. Expect the globals to need updated every season, as IOAH does not rely on hard coded URLs for schedules.... shucks.

*NEW* Autopilot mode
Autopilot mode asks for your username and password, then handles all the login info, html grabbing and scraping to create all of the iCal schedules for all of the nights. Sweet, huh?

Cheesy interactive mode on the command line
I said it was cheesy! Got python 2.4 and BeautifulSoup 3 installed, you simply gotta type python /path/to/ioah2ical.py from the command line and the program will ask for the saved html file, it's rough format, and where ya' wanna put the ics file. But why bother, I've already done that for all the nights and all the teams!

*Deprecated* What's up with the format options?
Well, there used to be an All Schedules page and a My Schedules page and they were formatted differently, and required different settings to scrape correctly. With recent changes to the IOAH web page, most likely you are viewing the All Schedules page.

Hackery
Yeah, there's some hacking going on (like the way I just copy/paste in the timezone declaration). But then again, for a project that was supposed to save me 1 hour of data-entry time, it took me many hours of coding to complete. So, I took some shortcuts and hacked around a little. I also left lots of comments and hackery exmaples in there as I was figuring things out. It's not cleaned up to say the least. That said, it does work and I plan to continue using this thing---just don't complain about stylistic things, eh?

FUTURE PLANS:

  • Automate the scheduleID discovery by parsing the HTML. Right now these values are hardcoded and will break every single season.
  • Backend script automation so that this web page is updated frequently.

UPDATES: Read the ioah2ical.py file for 'official' update listing.

9-9-2007 Added a super groovy AUTOPILOT mode. Try it out! It logs in for you, grabs all the schedules, saves them to a directory of your choice, then scrapes them and outputs iCalendar files. Super simple.

5-1-2007: Added ability to scrape multiple html files in a batch mode. Save your nights to a directory and send the script headed that way. Also cleaned up the interactive UI mode a little bit.