From 511b13bdcb91ca00dc8b45eb2e3700a21ea1f336 Mon Sep 17 00:00:00 2001 From: Gregory Danielson Date: Sun, 1 Nov 2020 13:41:52 -0600 Subject: [PATCH] Capture and return region from ipinfo lookup --- lib/location.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/location.py b/lib/location.py index 794a5f8..638a466 100644 --- a/lib/location.py +++ b/lib/location.py @@ -149,7 +149,10 @@ def ipinfo(ip_addr): r = requests.get('https://ipinfo.io/%s/json?token=%s' % (ip_addr, IPINFO_TOKEN)) if r.status_code == 200: - location = r.json()["city"], r.json()["country"] + r_json = r.json() + location = r_json["city"], r_json["region"], r_json["country"] + else: + location = None, None, None if location: ipcachewrite(ip_addr, location) return location