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 1 You must be signed in to fork a gist
  • Save pslobo/ed089e2abc8c86d53023 to your computer and use it in GitHub Desktop.
Save pslobo/ed089e2abc8c86d53023 to your computer and use it in GitHub Desktop.
Send a list of tasks received from Launch Center Pro to Reminders using GoodTask (formerly This Week)
#coding: utf-8
import urllib2
import webbrowser
import sys
events = sys.argv[1] # The list of items received from LCP
SEP = '/' # Change to any sperator you choose to use
url_str = '' # Initialize the x-callback-url
# Split the list by commas and iterate over each resulting item
for event in events.split(','):
# Split each item by the separator SEP
# and get tasks, dates and listname
try:
task = event.split(SEP)[0].strip()
except IndexError:
task = ''
try:
date = event.split(SEP)[1].strip()
except IndexError:
date = ''
try:
listname = event.split(SEP)[2].strip()
except IndexError:
listname = ''
# Create the task url
task_str = 'goodtask://add?text=%s&due=%s&list=%s' %(urllib2.quote(task,''), date, listname)
'''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
x-success entries.'''
if url_str == '':
url_str = task_str
else:
url_str = task_str+'&x-success='+urllib2.quote(url_str,'')
# Check to see if GoodTask is installed and open the URL if it is.
if webbrowser.can_open("goodtask://"):
webbrowser.open(url_str)
else:
print "GoodTask not installed"
@zamber
Copy link

zamber commented Dec 13, 2014

Hi, I made a less readable but more functional fork of this. I tested it only in the python console but it should work :).

>>> task = ["", "", ""]
>>> input = ["", "ola"]
>>> def totask(x):
...   task[x[0]] = x[1]
...
>>> list(enumerate(input))
[(0, ''), (1, 'ola')]
>>> map(totask, list(enumerate(input)))
[None, None]
>>> task
['', 'ola', '']

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment