fixed typo, added get_location_data.py
This commit is contained in:
parent
39f5c0b67e
commit
0ced3bdf4b
50
Python/get_location_data.py
Normal file
50
Python/get_location_data.py
Normal file
@ -0,0 +1,50 @@
|
||||
# Retrieve location info from Google Maps
|
||||
# Tested in Python 2.7
|
||||
# I used this script to get all information about GPS coordinates.
|
||||
# return Country,Town,Street or None when Google Maps breaks
|
||||
# Sometimes Google gives an error by multiple requests
|
||||
#
|
||||
# You can contact me by e-mail at floris@entermi.nl.
|
||||
#
|
||||
# Last updated 18 December, 2017.
|
||||
#
|
||||
# Floris van Enter
|
||||
# http://entermi.nl
|
||||
|
||||
import urllib.request
|
||||
import json
|
||||
|
||||
# define the function
|
||||
def getplace(lat, lon):
|
||||
lat = str(lat)
|
||||
lon = str(lon)
|
||||
url = "http://maps.googleapis.com/maps/api/geocode/json?"
|
||||
url += "latlng=%s,%s&sensor=false" % (lat, lon)
|
||||
v = urllib.request.urlopen(url).read()
|
||||
j = json.loads(v)
|
||||
|
||||
# Sometimes Google gives no data, check
|
||||
try:
|
||||
components = j['results'][0]['address_components']
|
||||
except:
|
||||
# Return message that Google failed
|
||||
print('Google Shizzle')
|
||||
return None
|
||||
else:
|
||||
# Return data
|
||||
country = town = street = None
|
||||
for c in components:
|
||||
if "route" in c['types']:
|
||||
street = c['long_name']
|
||||
if "country" in c['types']:
|
||||
country = c['long_name']
|
||||
if "locality" in c['types']:
|
||||
town = c['long_name']
|
||||
|
||||
print(lat + ", " + lon + " = " + str(country) + ", " + str(town) + ", " + str(street))
|
||||
return (str(country) + "," + str(town) + "," + str(street))
|
||||
|
||||
## Test runs
|
||||
# print(getplace(47.591737, 2.759478))
|
||||
# print(getplace(51.2, 0.1))
|
||||
# print(getplace(51.3, 0.1))
|
@ -17,6 +17,7 @@ DEST="/Users/floris/Downloads/done/"
|
||||
DEST_EXT=mp4
|
||||
HANDBRAKE_CLI=/Applications/HandBrakeCLI
|
||||
|
||||
# walkthrough all files in folder and put them in the HandBrakeCLI
|
||||
for FILE in "$SRC"/*
|
||||
do
|
||||
filename=$(basename "$FILE")
|
||||
|
Loading…
x
Reference in New Issue
Block a user