Save location name from geocoding, use it for !w when available

closes #71
This commit is contained in:
jesopo 2019-06-18 16:36:22 +01:00
parent 2ed1cf2e4a
commit d43cef6543
2 changed files with 9 additions and 5 deletions

View file

@ -19,5 +19,6 @@ class Module(ModuleManager.BaseModule):
timezone = result["annotations"]["timezone"]["name"]
lat = result["geometry"]["lat"]
lon = result["geometry"]["lng"]
name = result["formatted"]
return {"timezone": timezone, "lat": lat, "lon": lon}
return {"timezone": timezone, "lat": lat, "lon": lon, "name": name}

View file

@ -49,10 +49,13 @@ class Module(ModuleManager.BaseModule):
page = utils.http.request(URL_WEATHER, get_params=args, json=True)
if page:
if "weather" in page.data:
location_parts = [page.data["name"]]
if "country" in page.data["sys"]:
location_parts.append(page.data["sys"]["country"])
location_str = ", ".join(location_parts)
if "name" in location:
location_str = location["name"]
else:
location_parts = [page.data["name"]]
if "country" in page.data["sys"]:
location_parts.append(page.data["sys"]["country"])
location_str = ", ".join(location_parts)
celsius = "%dC" % page.data["main"]["temp"]
fahrenheit = "%dF" % ((page.data["main"]["temp"]*(9/5))+32)