Created
January 9, 2014 04:55
-
-
Save drdrang/8329584 to your computer and use it in GitHub Desktop.
A Pythonista script that gets the address, latitude, and longitude and sends them to Drafts.
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
import sys | |
import location, time | |
import urllib, webbrowser | |
# Handle argument, if present. | |
try: | |
a = sys.argv[1] | |
except IndexError: | |
a = '' | |
# Get the GPS info. | |
location.start_updates() | |
time.sleep(5) | |
loc = location.get_location() | |
addr = location.reverse_geocode(loc) | |
location.stop_updates() | |
# Assemble the output. | |
spot = '''%s%s | |
%s, %s %s | |
%.4f, %.4f''' % \ | |
(a, addr[0]['Street'], | |
addr[0]['City'], addr[0]['State'], addr[0]['ZIP'], | |
loc['latitude'], loc['longitude']) | |
# Send output to Drafts. | |
webbrowser.open("drafts://x-callback-url/create?text=" + urllib.quote(spot.encode('utf-8'))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment