mirror of
https://codeberg.org/scip/kleingebaeck.git
synced 2025-12-16 12:01:00 +01:00
Fix ad condition parsing (#118)
* fix #117: use details slice and pre-set to properly extract condition * also added the type part of the detail content (original de: "Art") --------- Co-authored-by: Thomas von Dein <tom@vondein.org>
This commit is contained in:
10
scrape.go
10
scrape.go
@@ -22,6 +22,7 @@ import (
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -124,6 +125,15 @@ 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 {
|
||||
if slices.Contains(CONDITIONS, detail) {
|
||||
advertisement.Condition = detail
|
||||
} else {
|
||||
advertisement.Type = detail
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
advertisement.CalculateExpire()
|
||||
|
||||
// prepare ad dir name
|
||||
|
||||
Reference in New Issue
Block a user