From e8cc9adc7fb559c476d19c268c8de2e94d86b875 Mon Sep 17 00:00:00 2001 From: Gregory Danielson Date: Sun, 15 Nov 2020 10:57:53 -0600 Subject: [PATCH] Rework geoip to include ccode, lat, long for cache purposes --- lib/location.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/location.py b/lib/location.py index 93f6bbd..50ac231 100644 --- a/lib/location.py +++ b/lib/location.py @@ -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