From 2884ab5c8247046bf38daf9d0d59905de3e4a10c Mon Sep 17 00:00:00 2001 From: Simon Junod Date: Sat, 26 Oct 2024 19:30:14 +0200 Subject: [PATCH] =?UTF-8?q?adapt=C3=A9=20=C3=A0=20la=20nouvelle=20api=20op?= =?UTF-8?q?enweathermap?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cambot/ephemeris.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cambot/ephemeris.py b/cambot/ephemeris.py index 72abc59..ce18857 100644 --- a/cambot/ephemeris.py +++ b/cambot/ephemeris.py @@ -45,17 +45,17 @@ def weather_emoji(_id): def weather(lat, lon): r = requests.get(f"https://api.openweathermap.org/data/2.5/" - f"onecall?lat={lat}&lon={lon}&appid={OWM_KEY}&lang=fr&units=metric") + f"forecast?lat={lat}&lon={lon}&appid={OWM_KEY}&lang=fr&units=metric") j = json.loads(r.text) next_hours = [] for i in (2, 8, 14): - hourly = j["hourly"][i] + hourly = j["list"][i] next_hours.append({"time": datetime.fromtimestamp(hourly["dt"]).strftime("%H:%M"), "emoji": weather_emoji(hourly["weather"][0]["id"]), "description": hourly["weather"][0]["description"], - "temp": round(hourly["temp"]), - "wind_speed": round(hourly["wind_speed"] * 3.6) + "temp": round(hourly["main"]["temp"]), + "wind_speed": round(hourly["wind"]["speed"] * 3.6) }) return next_hours