On Thu, Sep 24, 2009 at 12:29:38AM -0700, Oliver Zheng wrote:
I have a server. But this is still a one way sync, isn't it? How can I add an event on my Android phone (which adds it to Google Calendar) and have it show up in Remind?
I use the attached script to download several Google calendar ics files and convert them into reminder files, that I then INCLUDE into my ~/.reminders. The script is called from cron hourly.
It's a Python script, and requires wget in the PATH, and ical2rem in the PATH or $HOME/bin.
Most of my calendars are private, so I've removed them from the list, but I did leave the public US Holidays calendar, so the script should work out of the box. Just drop your ICS URLs in the urls list.
The script also does some processing of the incoming ICS file during the download, so that various things that I don't want in the reminder file don't show up. There are two: I strip "[wordsinbrackets] " prefixes from the ICS SUMMARY line (the name of the appointment), since I get some appointments from mailing lists that include the mailing list name, but I don't want that in my Remind calendar. I also truncate the LOCATION at the first newline, since that's sufficient to remind me without including a lot of detail that I don't want.
If you can write Python, you may be able to modify it more to your taste.
Hope this helps! Ed
#!/usr/bin/python import os import re import sys from subprocess import * urls = [ 'http://www.google.com/calendar/ical/usa__en%40holiday.calendar.google.com/public/basic.ics', ] home = os.environ['HOME'] calFile = home + '/.remind/calendar' tmpFile = calFile + '.tmp' bakFile = calFile + '.bak' icsFile = calFile + '.ics' out = open(tmpFile, 'w') ics = open(icsFile, 'w') # get all URLs to stdout p_wget = Popen('wget -q -O -'.split(' ') + urls, stdout=PIPE) # pipe to ical2rem p_ical2rem = Popen(['ical2rem'], stdin=PIPE, stdout=out, env={'TZ' : 'US/Eastern', 'PATH' : home + '/bin'}) inputRemains = True icsline = '' # make automated changes to calendars while downloading them while inputRemains: line = p_wget.stdout.readline() if ics: ics.write(line) if line == '' and p_wget.poll() != None: inputRemains = False line = '' # remove "[mailinglist] " sections from summary lines m = re.match(r'^(SUMMARY:)\[[\w-]*\] (.*$)', line) if m: line = m.group(1) + m.group(2) + "\n" # remove '\\n' and trailing string from LOCATION fields if re.match(r'^\s', line): icsline = icsline + line continue else: if icsline: m = re.match(r'(.*LOCATION:[^\\]*)\\n.*', icsline) if m: icsline = m.group(1) + "\n" p_ical2rem.stdin.write(icsline) icsline = line p_ical2rem.stdin.close() p_ical2rem.wait() if(os.path.exists(tmpFile) and os.stat(tmpFile).st_size > 0): if(os.path.exists(calFile)): os.rename(calFile, bakFile) os.rename(tmpFile, calFile)
signature.txt
Description: Digital signature
_______________________________________________ Remind-fans mailing list [email protected] http://lists.whatexit.org/mailman/listinfo/remind-fans
