quote wttr.in requests

This commit is contained in:
Brian S. Stephan 2021-04-24 12:59:12 -05:00
parent e64af1a0a1
commit 2f4156ce26
2 changed files with 3 additions and 2 deletions

View File

@ -33,7 +33,7 @@ class Weather(Plugin):
if len(queryitems) <= 0:
return
weather = weather_summary(queryitems[0])
weather = weather_summary(query)
weather_output = (f"Weather in {weather['location']}: {weather['current']['description']}. "
f"{weather['current']['temp_F']}/{weather['current']['temp_C']}, "
f"feels like {weather['current']['feels_like_temp_F']}/"

View File

@ -2,6 +2,7 @@
"""Get results of weather queries."""
import logging
import requests
from urllib.parse import quote
logger = logging.getLogger(__name__)
@ -9,7 +10,7 @@ logger = logging.getLogger(__name__)
def query_wttr_in(query):
"""Hit the wttr.in JSON API with the provided 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()
weather_info = response.json()