quote wttr.in requests
This commit is contained in:
parent
e64af1a0a1
commit
2f4156ce26
@ -33,7 +33,7 @@ class Weather(Plugin):
|
|||||||
if len(queryitems) <= 0:
|
if len(queryitems) <= 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
weather = weather_summary(queryitems[0])
|
weather = weather_summary(query)
|
||||||
weather_output = (f"Weather in {weather['location']}: {weather['current']['description']}. "
|
weather_output = (f"Weather in {weather['location']}: {weather['current']['description']}. "
|
||||||
f"{weather['current']['temp_F']}/{weather['current']['temp_C']}, "
|
f"{weather['current']['temp_F']}/{weather['current']['temp_C']}, "
|
||||||
f"feels like {weather['current']['feels_like_temp_F']}/"
|
f"feels like {weather['current']['feels_like_temp_F']}/"
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
"""Get results of weather queries."""
|
"""Get results of weather queries."""
|
||||||
import logging
|
import logging
|
||||||
import requests
|
import requests
|
||||||
|
from urllib.parse import quote
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -9,7 +10,7 @@ logger = logging.getLogger(__name__)
|
|||||||
def query_wttr_in(query):
|
def query_wttr_in(query):
|
||||||
"""Hit the wttr.in JSON API with the provided query."""
|
"""Hit the wttr.in JSON API with the provided query."""
|
||||||
logger.info(f"about to query wttr.in with '{query}'")
|
logger.info(f"about to query wttr.in with '{query}'")
|
||||||
response = requests.get(f'http://wttr.in/{query}?format=j1')
|
response = requests.get(f'http://wttr.in/{quote(query)}?format=j1')
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
|
|
||||||
weather_info = response.json()
|
weather_info = response.json()
|
||||||
|
Loading…
Reference in New Issue
Block a user