Created
February 23, 2014 22:16
-
-
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 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
# 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