From 51e54a610bc29ca51fd59774ab90eebc1197c417 Mon Sep 17 00:00:00 2001 From: William Brawner Date: Thu, 26 Dec 2019 21:39:41 -0600 Subject: [PATCH] Initial commit Signed-off-by: William Brawner --- README.md | 7 +++++++ gcal-to-ical.py | 20 ++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 README.md create mode 100755 gcal-to-ical.py diff --git a/README.md b/README.md new file mode 100644 index 0000000..a761470 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +# gcal to ical Converter + +This is a quick and dirty script to convert a Google Calendar link into an ical link that can be used in a Nextcloud calendar subscription for example. + + + Usage: ./gcal-to-ical.py + diff --git a/gcal-to-ical.py b/gcal-to-ical.py new file mode 100755 index 0000000..b5a79f3 --- /dev/null +++ b/gcal-to-ical.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 + +from urllib.parse import urlparse,parse_qsl +import sys +from pprint import pprint + +ICAL_FORMAT = 'https://calendar.google.com/calendar/ical/{}/public/basic.ics' + +def main(cli_input): + gcal_url = o = urlparse(cli_input) + query_string = gcal_url.query + src = parse_qsl(query_string) + for pair in parse_qsl(query_string): + if pair[0] == 'src': + print(ICAL_FORMAT.format(pair[1])) + return + +if __name__ == '__main__': + main(sys.argv[1]) +