mirror of
https://github.com/chubin/wttr.in.git
synced 2025-08-16 08:38:15 +02:00
Rework geoip to include ccode, lat, long for cache purposes
This commit is contained in:
@ -165,10 +165,11 @@ def ipinfo(ip_addr):
|
|||||||
def geoip(ip_addr):
|
def geoip(ip_addr):
|
||||||
try:
|
try:
|
||||||
response = GEOIP_READER.city(ip_addr)
|
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:
|
except geoip2.errors.AddressNotFoundError:
|
||||||
return None, None, None
|
return None
|
||||||
return city, region, country
|
return city, region, country, ccode, lat, long
|
||||||
|
|
||||||
|
|
||||||
def workaround(country):
|
def workaround(country):
|
||||||
# workaround for strange bug with the country name
|
# workaround for strange bug with the country name
|
||||||
|
Reference in New Issue
Block a user