mirror of
https://github.com/gensokyo-zone/infrastructure.git
synced 2026-02-09 12:29:19 -08:00
Weather script changes.
This commit is contained in:
parent
0257ccd90a
commit
0db7375055
2 changed files with 7 additions and 6 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue