modified: app.py

modified:   templates/weather.html
This commit is contained in:
simon
2026-04-24 09:45:09 +02:00
parent 08a8bb2e13
commit c6cfce6bda
2 changed files with 17 additions and 6 deletions

17
app.py
View File

@@ -75,7 +75,8 @@ MOSMIX_PARAMS = [
# ── Wetter-Icons (OpenWeatherMap CDN) ────────────────────────────────────────
_OWM = "https://openweathermap.org/img/wn/"
ICON_URLS = {
# Day icons keyed by the emoji that weather_icon() / pick_daily_icon() returns
ICON_URLS_DAY = {
"☀️": _OWM + "01d@2x.png", # klar
"": _OWM + "02d@2x.png", # leicht bewölkt
"☁️": _OWM + "04d@2x.png", # bedeckt
@@ -83,9 +84,19 @@ ICON_URLS = {
"🌦️": _OWM + "09d@2x.png", # Regenschauer
"❄️": _OWM + "13d@2x.png", # Schnee
}
# Overrides for night hours (205 Uhr): only clear/partly change visually
ICON_URLS_NIGHT = {
"☀️": _OWM + "01n@2x.png", # klare Nacht (Mond)
"": _OWM + "02n@2x.png", # leicht bewölkt nachts
}
def _icon_url(emoji):
return ICON_URLS.get(str(emoji), _OWM + "03d@2x.png")
def _icon_url(emoji, hour=12):
"""Return OWM icon URL. Uses night variants for clear/partly-cloudy between 205 Uhr."""
e = str(emoji)
is_night = hour >= 20 or hour < 6
if is_night and e in ICON_URLS_NIGHT:
return ICON_URLS_NIGHT[e]
return ICON_URLS_DAY.get(e, _OWM + "03d@2x.png")
def _get_berlin():
try: