Skip to content

Instantly share code, notes, and snippets.

@drunkensouljah
Forked from philgruneich/latest_draft.py
Created June 15, 2016 17:25
Show Gist options
  • Save drunkensouljah/ffa033b7c13065bca5e5988e0114453d to your computer and use it in GitHub Desktop.
Save drunkensouljah/ffa033b7c13065bca5e5988e0114453d to your computer and use it in GitHub Desktop.
Open latest Draft article on either Byword or 1Writer
from requests import get
from json import loads
from urllib import quote
from webbrowser import open
email = 'YOUR EMAIL'
password = 'YOUR PASSWORD'
r = get('https://draftin.com/api/v1/documents.json', auth=(email,password))
data = loads(r.content)
title = quote(data[0]['name'].encode('utf-8'))
article = quote(data[0]['content'].encode('utf-8'))
callback = 'onewriter://x-callback-url/create?name=' + title + '&text=' + article
#callback = 'byword://x-callback-url/new?name' + title + '&text=' + article
open(callback)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment