modified: app.py
modified: templates/weather.html
This commit is contained in:
17
app.py
17
app.py
@@ -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 (20–5 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 20–5 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:
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
<div class="hero-temp">{{ current.temp_c if current.temp_c is not none else "–" }}°</div>
|
||||
<div class="hero-desc">
|
||||
<div class="hero-icon-big">
|
||||
<img class="wx-icon wx-icon--hero" src="{{ icon_url(current.icon) }}" alt="{{ current.icon }}">
|
||||
<img class="wx-icon wx-icon--hero" src="{{ icon_url(current.icon, current.datetime.hour if current.datetime is not none and current.datetime is not string else 12) }}" alt="{{ current.icon }}">
|
||||
</div>
|
||||
<div class="hero-stats-mini">
|
||||
{% if current.wind_kmh is not none %}
|
||||
@@ -171,7 +171,7 @@
|
||||
{% else %}{{ h.datetime.strftime('%d.%m.') }}{% endif %}
|
||||
</div>
|
||||
<div class="hcard-icon">
|
||||
<img class="wx-icon" src="{{ icon_url(h.icon) }}" alt="{{ h.icon }}">
|
||||
<img class="wx-icon" src="{{ icon_url(h.icon, h.datetime.hour if h.datetime is not none and h.datetime is not string else 12) }}" alt="{{ h.icon }}">
|
||||
</div>
|
||||
<div class="hcard-temp">
|
||||
{% if h.temp_c is not none %}{{ h.temp_c }}°{% else %}–{% endif %}
|
||||
@@ -231,7 +231,7 @@
|
||||
<div class="drow">
|
||||
<div class="drow-left">
|
||||
<span class="drow-icon">
|
||||
<img class="wx-icon wx-icon--sm" src="{{ icon_url(d.icon) }}" alt="{{ d.icon }}">
|
||||
<img class="wx-icon wx-icon--sm" src="{{ icon_url(d.icon, 12) }}" alt="{{ d.icon }}">
|
||||
</span>
|
||||
<div class="drow-date-wrap">
|
||||
<span class="drow-dow">
|
||||
|
||||
Reference in New Issue
Block a user