mirror of
https://codeberg.org/scip/kleingebaeck.git
synced 2025-12-16 12:01:00 +01:00
Generic attributes (#120)
* fix #117: use a generic attribute parser, still support fixed attrs
This commit is contained in:
13
scrape.go
13
scrape.go
@@ -22,7 +22,6 @@ import (
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -125,17 +124,7 @@ func ScrapeAd(fetch *Fetcher, uri string) error {
|
||||
return fmt.Errorf("could not extract ad data from page, got empty struct")
|
||||
}
|
||||
|
||||
for _, detail := range advertisement.Details {
|
||||
switch {
|
||||
case slices.Contains(CONDITIONS, detail):
|
||||
advertisement.Condition = detail
|
||||
case slices.Contains(COLORS, detail):
|
||||
advertisement.Color = detail
|
||||
default:
|
||||
advertisement.Type = detail
|
||||
}
|
||||
}
|
||||
|
||||
advertisement.DecodeAttributes()
|
||||
advertisement.CalculateExpire()
|
||||
|
||||
// prepare ad dir name
|
||||
|
||||
Reference in New Issue
Block a user