Copyright 2009-2014 Richard Fearn
mythcal is a simple script that synchronizes your MythTV recording schedule to a Google calendar.
Leaving my MythTV server on 24/7 wastes electricity, but I don't want to forget to turn it on to record programmes. I wrote this to make it easy to keep track of upcoming recordings.
-
Create a calendar in Google Calendar that will hold your MythTV programmes. DO NOT USE YOUR MAIN GOOGLE CALENDAR! YOU MUST CREATE A NEW CALENDAR! mythcal synchronises your programmes by deleting everything from the calendar, then adding an event for each programme.
-
Create a new directory somewhere on your MythTV server and copy the script (
mythcal
) and the template configuration file (mythcal.conf.template
) into the directory. -
Install the required packages:
-
MythTV Python bindings (
"libmyth-python"
for Ubuntu;"python-MythTV"
from RPM Fusion free for Fedora). -
pytz (
"python-tz"
for Debian and Ubuntu;"pytz"
for Fedora). -
Google APIs Client Library for Python (
"python-googleapi"
for Ubuntu).
-
-
Copy the template configuration file,
mythcal.conf.template
, tomythcal.conf
, and add the missing settings. The sections are:-
[mythtv]
- details about your MythTV server."timezone"
should be a zoneinfo time zone name such as"Europe/London"
. To find an appropriate time zone name, use the suppliedtimezones
script (see below). -
[calendar]
- details about your Google Calendar. To find the"id"
, go into Google Calendar Settings, open the "Calendars" tab, click the calendar you want to use, and look in the "Calendar Address" section. The Calendar ID should be displayed: it will look something like"abc123def@group.calendar.google.com"
. Please remember: USE A SEPARATE CALENDAR FOR MYTHCAL, or your appointments will be deleted!
-
-
Give mythcal permission to access your calendar. Run
mythcal --auth
and follow the instructions. -
Run mythcal manually with the
--dry-run
or-n
option. This will tell you what's going to be changed in your Google Calendar. Hopefully it won't tell you that your important appointments are going to be deleted, because you'll be using a separate calendar for mythcal! -
If everything looks good, set up a cron job which will execute mythcal as often as you like. The command being run should look something like this:
cd /path/to/mythcal/directory && ./mythcal
The timezones
script can be used to find an appropriate time zone name.
Running it with no parameters lists all time zone names. If a parameter is
given, the script does a case-insensitive search for time zones containing
that text. For example:
$ ./timezones york
America/New_York
Thanks to Michael T. Dean and Raymond Wagner for pointing me in the direction of the MythTV Python bindings.
Google Calendar APIs and Tools - Data API Developer's Guide: Python
Google Data Protocol - Batch Processing in the Google Data Protocol