Last active
December 14, 2015 19:09
-
-
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
This file contains hidden or 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
# 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