Skip to content

Instantly share code, notes, and snippets.

@esprengle
Forked from maddievision/Drafts.py
Created April 10, 2021 20:19
Show Gist options
  • Save esprengle/9b8896b2af24c12a148c98250e206e54 to your computer and use it in GitHub Desktop.
Save esprengle/9b8896b2af24c12a148c98250e206e54 to your computer and use it in GitHub Desktop.
Very simple wrapper for Drafts URL scheme for Pythonista http://omz-software.com/pythonista
import urllib
import webbrowser
URL_BASE = "drafts://x-callback-url/create?"
CALLBACK_URL_BASE = "pythonista://"
def do_action(actiontype,txt,cb=CALLBACK_URL_BASE):
surl = URL_BASE + 'text=' + urllib.quote(txt) + '&action=' + urllib.quote(actiontype) + '&x-success=' + urllib.quote(cb)
webbrowser.open(surl)
print "Action Complete"
def message(txt,cb=CALLBACK_URL_BASE):
do_action('Message',txt,cb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment