Skip to content

Instantly share code, notes, and snippets.

@pslobo pslobo/list2goodtask.py Secret
Last active Aug 29, 2015

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

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
You can’t perform that action at this time.