Skip to content

Instantly share code, notes, and snippets.

@pslobo
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pslobo/25af95742e1480210e2e to your computer and use it in GitHub Desktop.
Save pslobo/25af95742e1480210e2e to your computer and use it in GitHub Desktop.
Send a list of tasks received from Launch Center Pro to Reminders using Fantastical 2
#coding: utf-8
import urllib2
import webbrowser
import sys
tasks = sys.argv[1] # The list of items received from LCP
url_str = '' # Initialize the x-callback-url
# Split the list by commas and iterate over each resulting item
for task in tasks.split(','):
'''Check to see if there is already an item in the x-callback-url,
if not, create it, if there is then add task_str + &x-success followed by
a the URL-encoded url_str. This respects the needed encoding of nested'''
if url_str == '':
url_str += 'fantastical2://x-callback-url/parse?sentence='+urllib2.quote(task,'')
else:
url_str = 'fantastical2://x-callback-url/parse?sentence='+urllib2.quote(task,'')+'&x-success='+urllib2.quote(url_str,'')
# Check to see if Fantastical is installed and open the URL if it is.
if webbrowser.can_open("fantastical2://"):
webbrowser.open(url_str)
else:
print "Fantastical not installed"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment