mirror of
https://github.com/chubin/wttr.in
synced 2025-01-26 10:45:01 +00:00
Rework geoip to include ccode, lat, long for cache purposes
This commit is contained in:
parent
88cd84b5d2
commit
e8cc9adc7f
1 changed files with 4 additions and 3 deletions
|
@ -165,10 +165,11 @@ def ipinfo(ip_addr):
|
|||
def geoip(ip_addr):
|
||||
try:
|
||||
response = GEOIP_READER.city(ip_addr)
|
||||
city, region, country = response.city.name, response.subdivisions.name, response.country.name
|
||||
city, region, country, ccode, lat, long = response.city.name, response.subdivisions.name, response.country.name, response.country.iso_code, response.location.latitude, response.location.longitude
|
||||
except geoip2.errors.AddressNotFoundError:
|
||||
return None, None, None
|
||||
return city, region, country
|
||||
return None
|
||||
return city, region, country, ccode, lat, long
|
||||
|
||||
|
||||
def workaround(country):
|
||||
# workaround for strange bug with the country name
|
||||
|
|
Loading…
Reference in a new issue