vacation day fix

This commit is contained in:
2026-01-14 16:58:08 +01:00
parent aaa86facda
commit 97f6a976cc
+20 -7
View File
@@ -1,8 +1,3 @@
apiVersion: v1
kind: Namespace
metadata:
name: glance-system
---
apiVersion: apps/v1
kind: Deployment
metadata:
@@ -52,6 +47,7 @@ data:
app.py: |
import os
import time
import re
from typing import List, Dict, Any, Optional
import requests
@@ -139,17 +135,34 @@ data:
# Daily columns (bottom forecast table: .ik.daily-forecast-container .ik.dailyForecastCol)
daily: List[Dict[str, Any]] = []
for col in soup.select(".ik.daily-forecast-container .ik.dailyForecastCol")[:7]:
for col in soup.select(".ik.daily-forecast-container .ik.dailyForecastCol")[:15]:
dow_el = col.select_one(".ik.dfDay")
icon_el = col.select_one("img.ik.forecast-icon")
# Normal structure (most days)
tmax_el = col.select_one("div.ik.max")
tmin_el = col.select_one("div.ik.min")
dow = dow_el.get_text(strip=True) if dow_el else ""
icon = _abs_url(icon_el.get("src") if icon_el else None)
tmax = _to_int_temp(tmax_el.get_text(strip=True) if tmax_el else "")
tmin = _to_int_temp(tmin_el.get_text(strip=True) if tmin_el else "")
# Fallback structure (e.g. "vacation" days) where div.ik.max/min are missing
# In those cases the visible temps are usually the first two numeric <a> texts
# inside .ik.min-max-container (order: max, min).
if tmax is None or tmin is None:
vals: List[str] = []
for a in col.select(".ik.min-max-container a"):
txt = a.get_text(strip=True)
if re.fullmatch(r"-?\d+", txt or ""):
vals.append(txt)
if len(vals) >= 2:
tmax = _to_int_temp(vals[0])
tmin = _to_int_temp(vals[1])
# Keep only rows that look valid
if dow and (tmin is not None) and (tmax is not None):
daily.append(
@@ -161,7 +174,7 @@ data:
}
)
# Limit to 5 days for your widget
# Limit to 5 days for your widget (first 5 columns in the table, including "vacation" days)
daily = daily[:5]
return {