The last couple of days, I've been working on a set of Ruby scripts to download XMLTV format (or some derivative) schedules from tv.swedb.se, process them against rulesets, and export the intersection as reminders in an iCalendar (.ics) file that you can subscribe to with iCal.
An archive of the scripts including documentation/installation instructions is available as iCalTV.zip.
The documentation/installation instructions, in Swedish only for now, are available by themselves as iCalTV.html.
Though that documentation is in Swedish only, the code and its comments are in English, so if anyone wants to adapt this for another country, it shouldn't be too hard to follow. I will add English documentation if it turns out anyone wants it.
Until then, this is how iCalTV works in brief:
Install the set of Ruby scripts and support files into e.g.
grabber.rb to run every couple of days. That script retrieves new schedules and also runs
cleaner.rb, which removes expired schedules, and
icaltv.rb, which is the rule/calendar engine.
Data is stored in
~/Library/Xmltv, intended to be the shared space for everything that works with this data. That could include TV listing widgets, tools to search in schedules or whatever.
channels.xml, listing the channels you're interested in, and
rulesets.xml, containing, well, rulesets. A ruleset has an optional name, optional settings for how long before a show to notify, optional settings for the notification sound, and then a set of rules and the setting whether all rules need match, or just any one.
A ruleset might look like this:
<rule attribute="name" condition="begins-with">CSI</rule>
<rule attribute="channel" condition="is">Kanal 5</rule>
<rule attribute="plays" condition="within">08:00-02:30</rule>
In addition to the scheduling,
grabber.rb needs to be run manually whenever you add new channels (unless you want to wait for the scheduled update), and
icaltv.rb needs to be run manually whenever the rulesets are changed. I plan for some interface to the channels and rulesets that would handle this itself.
icaltv.rb is run, it compares the schedules downloaded for your channels to the rulesets, and exports an iCalendar file of your favorite shows to
All that remains is to toggle on Personal Web Sharing, and then subscribe to the file through your web server, in iCal, keeping in mind not to leave "Remove alarms" checked.