Generic attributes (#120)

* fix #117: use a generic attribute parser, still support fixed attrs
This commit is contained in:
T.v.Dein
2025-02-10 18:20:54 +01:00
committed by GitHub
parent 09948a6b39
commit 46be48af38
8 changed files with 118 additions and 45 deletions

View File

@@ -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