Weather script changes.

This commit is contained in:
kat witch 2021-02-13 01:46:28 +00:00 committed by kat
parent 0257ccd90a
commit 0db7375055
2 changed files with 7 additions and 6 deletions

View file

@ -25,11 +25,11 @@ weather_icons = {
"Tornado": ""
}
def degrees_to_cardinal(d):
dirs = ["N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE",
"S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW"]
ix = int((d + 11.25)/22.5)
return dirs[ix % 16]
#def degrees_to_cardinal(d):
# dirs = ["N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE",
# "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW"]
# ix = int((d + 11.25)/22.5)
# return dirs[ix % 16]
response = requests.get(url)
data = json.loads(response.text)
@ -40,7 +40,7 @@ weather_icon = weather_icons[condition]
temperature = f"{round(data['main']['temp'])}°C"
feels_like_temperature = f"{round(data['main']['feels_like'])}°C"
humidity = f"{data['main']['humidity']}%"
wind = f"{round(data['wind']['speed'])}m/s {degrees_to_cardinal(data['wind']['deg'])}"
wind = f"{round(data['wind']['speed'])}m/s" # {degrees_to_cardinal(data['wind']['deg'])}"
end_string = f"{weather_icon} {temperature} {feels_like_temperature} {humidity} {wind}"
print(end_string)