-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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