Skip to content

Instantly share code, notes, and snippets.

@ChewingPencils
Last active December 14, 2015 19:09
Show Gist options
  • Save ChewingPencils/5134571 to your computer and use it in GitHub Desktop.
Save ChewingPencils/5134571 to your computer and use it in GitHub Desktop.
A Pythonista helper script for a Drafts app action used to create a Quotebook app entry. This is the bare-bones version. For error detection, logging and documentation see: https://gist.github.com/ChewingPencils/5134533
# Sean Korzdorfer
# 2013-03-10
# quote_bits.py
import sys
import urllib
import webbrowser
def main():
quoteBits = sys.argv[1].split('\n')
webbrowser.open(parseBits(quoteBits))
def parseBits(quoteBits):
quoteURL = 'quotebook://add?quote=' + urllib.quote(quoteBits[0].encode('utf8'))
if len(quoteBits) >= 2 and quoteBits[1] != '':
quoteURL = quoteURL + '&author=' + urllib.quote(quoteBits[1].encode('utf8'))
if len(quoteBits) >= 3 and quoteBits[2] != '':
quoteURL = quoteURL + '&source=' + urllib.quote(quoteBits[2].encode('utf8'))
if len(quoteBits) == 4 and quoteBits[3] != '':
quoteURL = quoteURL + '&rating=' + urllib.quote(quoteBits[3].encode('utf8'))
return quoteURL
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment