Adds missing fields to the DuckDuckGo weather extractor as described in #51:
Hourly forecast: New HourlyForecast struct with Time, Temp, Condition, Precipitation, and IconHint fields. Extracted via .module__hourly-item elements.
Precipitation percentage: Added Precipitation int field to both DayForecast and HourlyForecast. Uses -1 sentinel for "unavailable" (matches mort's convention).
Icon hints: Added IconHint string field to both structs. Reads icon type from element aria-label, title, or alt attributes (in priority order), providing reliable weather categorization (e.g., "PartlyCloudy", "Snow", "MostlyCloudy").
Struct changes
typeWeatherDatastruct{// ... existing fields ...Hourly[]HourlyForecast// NEW}typeDayForecaststruct{// ... existing fields ...Precipitationint// NEW: 0-100, -1 if unavailableIconHintstring// NEW: from element attributes}typeHourlyForecaststruct{// NEWTimestringTempfloat64ConditionstringPrecipitationint// 0-100, -1 if unavailableIconHintstring// from element attributes}
New helper
extractIconHint(nodes) reads icon type from aria-label > title > alt attribute priority chain, matching the same approach used in mort's weather2 module.
Test plan
TestExtractWeather - updated with hourly items, precipitation, and icon hints
TestGetWeather_MockBrowser - verifies hourly data flows through full path
TestExtractWeather_Empty - verifies zero hourly data on empty doc
TestExtractWeather_NoPrecipitation - verifies -1 sentinel when no precip element
TestExtractIconHint_Priority - verifies aria-label > title > alt fallback chain
## Summary
Adds missing fields to the DuckDuckGo weather extractor as described in #51:
- **Hourly forecast**: New `HourlyForecast` struct with `Time`, `Temp`, `Condition`, `Precipitation`, and `IconHint` fields. Extracted via `.module__hourly-item` elements.
- **Precipitation percentage**: Added `Precipitation int` field to both `DayForecast` and `HourlyForecast`. Uses -1 sentinel for "unavailable" (matches mort's convention).
- **Icon hints**: Added `IconHint string` field to both structs. Reads icon type from element `aria-label`, `title`, or `alt` attributes (in priority order), providing reliable weather categorization (e.g., "PartlyCloudy", "Snow", "MostlyCloudy").
### Struct changes
```go
type WeatherData struct {
// ... existing fields ...
Hourly []HourlyForecast // NEW
}
type DayForecast struct {
// ... existing fields ...
Precipitation int // NEW: 0-100, -1 if unavailable
IconHint string // NEW: from element attributes
}
type HourlyForecast struct { // NEW
Time string
Temp float64
Condition string
Precipitation int // 0-100, -1 if unavailable
IconHint string // from element attributes
}
```
### New helper
`extractIconHint(nodes)` reads icon type from aria-label > title > alt attribute priority chain, matching the same approach used in mort's `weather2` module.
## Test plan
- [x] `TestExtractWeather` - updated with hourly items, precipitation, and icon hints
- [x] `TestGetWeather_MockBrowser` - verifies hourly data flows through full path
- [x] `TestExtractWeather_Empty` - verifies zero hourly data on empty doc
- [x] `TestExtractWeather_NoPrecipitation` - verifies -1 sentinel when no precip element
- [x] `TestExtractIconHint_Priority` - verifies aria-label > title > alt fallback chain
- [x] Full test suite passes (`go test ./...`)
Closes #51
Add HourlyForecast struct and Hourly field to WeatherData for hourly
temperature/condition data. Add Precipitation (int, -1 if unavailable)
and IconHint (from aria-label/title/alt attributes) to both DayForecast
and HourlyForecast. This enables downstream consumers like mort to
replace inline DuckDuckGo scraping with a single GetWeather() call.
Closes#51
Co-Authored-By: Claude Opus 4.6 <[email protected]>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary
Adds missing fields to the DuckDuckGo weather extractor as described in #51:
HourlyForecaststruct withTime,Temp,Condition,Precipitation, andIconHintfields. Extracted via.module__hourly-itemelements.Precipitation intfield to bothDayForecastandHourlyForecast. Uses -1 sentinel for "unavailable" (matches mort's convention).IconHint stringfield to both structs. Reads icon type from elementaria-label,title, oraltattributes (in priority order), providing reliable weather categorization (e.g., "PartlyCloudy", "Snow", "MostlyCloudy").Struct changes
New helper
extractIconHint(nodes)reads icon type from aria-label > title > alt attribute priority chain, matching the same approach used in mort'sweather2module.Test plan
TestExtractWeather- updated with hourly items, precipitation, and icon hintsTestGetWeather_MockBrowser- verifies hourly data flows through full pathTestExtractWeather_Empty- verifies zero hourly data on empty docTestExtractWeather_NoPrecipitation- verifies -1 sentinel when no precip elementTestExtractIconHint_Priority- verifies aria-label > title > alt fallback chaingo test ./...)Closes #51