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:
T.v.Dein
2025-02-06 13:48:20 +01:00
committed by GitHub
parent cd3d00adbe
commit bc01391872
10 changed files with 40 additions and 14 deletions

View File

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