Skip to content

Instantly share code, notes, and snippets.

@cowpi
Created February 23, 2014 22:16
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 cowpi/9178153 to your computer and use it in GitHub Desktop.
Save cowpi/9178153 to your computer and use it in GitHub Desktop.
This little Pythonista script formats a callback URL for the iPhone/iPad Due app for 9 consecutive days of reminders for a novena prayer. The script is initiated from Launch Center Pro for each day with the following callback URL pythonista://novenaToDue?action=run&args=nn where nn is the day of novena (1..9).
# This script formats a callback url for the Due app to send a reminder for
# each day of a Novena for the Dead. This script is called by Launch Center Pro
# with a sys argument nn, where nn is which day of the novena (1..9).
# The first day of the novena is set to begin +1 days of current date.
# Time is set for 5:15 of current time zone.
import datetime
import time
import webbrowser
import sys
def get_url(nn):
"""Formats a callback url for Due app. nn = day of novena"""
if time.daylight == 1:
tmzn = time.tzname[0] # Standard time
else:
tmzn = time.tzname[1] # Daylight savings
tmzn = '&timezone=' + tmzn
now = datetime.datetime.now()
dt = datetime.datetime(now.year, now.month, now.day, 5, 15, 0)
today = time.mktime(dt.timetuple())
timestamp = today + nn * 60 * 60 * 24
appurl = 'due://x-callback-url/add?'
returnurl = '&x-source=Launch&x-success=launch://x-callback-url/returnAction'
# If Due used return callback properly:
# returnurl = '&x-source=Pythonista&x-success=%7B%7Bpythonista://x-callback-url/novenaToDue?action=run&argv=' + str(nn+1) + '%7D%7D'
titestr = 'title=Day%20' + str(nn) + '%20-%20Novena%20for%20the%20Dead'
duedate = '&duedate=' + str(int(timestamp))
dueurl = appurl + titestr + duedate + tmzn + returnurl
return dueurl
if len(sys.argv) > 1:
nn = int(sys.argv[1])
else:
nn = 1
if nn >= 1 and nn <= 9:
thisurl = get_url(nn)
webbrowser.open(thisurl)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment