Save location name from geocoding, use it for !w when available
closes #71
This commit is contained in:
parent
2ed1cf2e4a
commit
d43cef6543
2 changed files with 9 additions and 5 deletions
|
@ -19,5 +19,6 @@ class Module(ModuleManager.BaseModule):
|
||||||
timezone = result["annotations"]["timezone"]["name"]
|
timezone = result["annotations"]["timezone"]["name"]
|
||||||
lat = result["geometry"]["lat"]
|
lat = result["geometry"]["lat"]
|
||||||
lon = result["geometry"]["lng"]
|
lon = result["geometry"]["lng"]
|
||||||
|
name = result["formatted"]
|
||||||
|
|
||||||
return {"timezone": timezone, "lat": lat, "lon": lon}
|
return {"timezone": timezone, "lat": lat, "lon": lon, "name": name}
|
||||||
|
|
|
@ -49,10 +49,13 @@ class Module(ModuleManager.BaseModule):
|
||||||
page = utils.http.request(URL_WEATHER, get_params=args, json=True)
|
page = utils.http.request(URL_WEATHER, get_params=args, json=True)
|
||||||
if page:
|
if page:
|
||||||
if "weather" in page.data:
|
if "weather" in page.data:
|
||||||
location_parts = [page.data["name"]]
|
if "name" in location:
|
||||||
if "country" in page.data["sys"]:
|
location_str = location["name"]
|
||||||
location_parts.append(page.data["sys"]["country"])
|
else:
|
||||||
location_str = ", ".join(location_parts)
|
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"]
|
celsius = "%dC" % page.data["main"]["temp"]
|
||||||
fahrenheit = "%dF" % ((page.data["main"]["temp"]*(9/5))+32)
|
fahrenheit = "%dF" % ((page.data["main"]["temp"]*(9/5))+32)
|
||||||
|
|
Loading…
Reference in a new issue