diff --git a/glance-system/glance-kisfenyo.yaml b/glance-system/glance-kisfenyo.yaml index cad5722..926d6fe 100644 --- a/glance-system/glance-kisfenyo.yaml +++ b/glance-system/glance-kisfenyo.yaml @@ -369,102 +369,102 @@ data: - type: custom-api url: https://www.idokep.hu/idojaras/Budapest cache: 15m - skip-json-validation: true # Mandatory for HTML scraping + skip-json-validation: true style: grid-column: span 4 grid-row: span 3 template: | - {{/* 1. Extract Current Weather Data */}} + {{/* 1. Extract Body and Current Data */}} {{ $body := .Body }} - {{ $temp := findSubmatch `current-temperature">([^˚<]+)` $body }} - {{ $cond := findSubmatch `current-weather">([^<]+)` $body }} - {{ $icon := findSubmatch `forecast-bigicon"[^>]+src="([^"]+)"` $body }} - {{ $sunrise := findSubmatch `Napkelte ([0-9:]+)` $body }} - {{ $sunset := findSubmatch `Napnyugta ([0-9:]+)` $body }} - + {{ $temp := findSubmatch "current-temperature\">([^˚<]+)" $body | trimSpace }} + {{ $cond := findSubmatch "current-weather\">([^<]+)" $body | trimSpace }} + {{ $icon := findSubmatch "forecast-bigicon\"[^>]+src=\"([^\"]+)\"" $body }} + {{ $sunrise := findSubmatch "Napkelte ([0-9:]+)" $body }} + {{ $sunset := findSubmatch "Napnyugta ([0-9:]+)" $body }} + + {{/* 2. Split HTML by the Forecast Column class to get daily blocks */}} + {{ $parts := split $body "
" }} +
- {{/* Current Section */}} -
+ {{/* Current Conditions Section */}} +
-
Budapest
-
{{ $temp }}°
-
{{ $cond }}
-
- ↑ {{ $sunrise }} - ↓ {{ $sunset }} -
+

Budapest

+
{{ $temp }}°C
+
{{ $cond }}
- weather + weather
- {{/* Daily Forecast Section */}} -
- {{/* findMatches returns a slice of the daily forecast columns */}} - {{ $blocks := findMatches `(?s)
.*?
` $body }} - {{ range $i, $block := $blocks }} - {{ if lt $i 5 }} {{/* Display only the next 5 days */}} - {{ $d_num := findSubmatch `dfDayNum">([0-9]+)` $block }} - {{ $d_name := findSubmatch `dfDay">([^<]+)` $block }} - {{ $d_icon := findSubmatch `src="([^"]+)"` $block }} - {{ $d_max := findSubmatch `max">([^<]+)` $block }} - {{ $d_min := findSubmatch `min">([^<]+)` $block }} + {{/* Sunrise/Sunset info */}} +
+ ↑ {{ $sunrise }} + ↓ {{ $sunset }} +
+ + {{/* 5-Day Forecast List */}} +
+ {{ range $i := list 1 2 3 4 5 }} + {{ $block := index $parts $i }} + {{ if $block }} + {{ $d_num := findSubmatch "dfDayNum\">([0-9]+)" $block }} + {{ $d_name := findSubmatch "dfDay\">([^<]+)" $block }} + {{ $d_icon := findSubmatch "src=\"([^\"]+)\"" $block }} + {{ $d_max := findSubmatch "class=\"max\">([^<]+)" $block }} + {{ $d_min := findSubmatch "class=\"min\">([^<]+)" $block }} -
- {{ $d_num }} {{ $d_name }} - - {{ $d_min }}° -
-
+
+ {{ $d_num }} {{ $d_name }} + + {{ $d_min }}° +
+
- {{ $d_max }}° + {{ $d_max }}°
{{ end }} {{ end }}
{{/* Footer Link */}} -