fix #117: use details slice and pre-set to properly extract condition

This commit is contained in:
2025-02-06 10:29:24 +01:00
parent cd3d00adbe
commit 22da878f27
6 changed files with 25 additions and 9 deletions

View File

@@ -22,6 +22,7 @@ import (
"fmt"
"log/slog"
"path/filepath"
"slices"
"strconv"
"strings"
"time"
@@ -124,6 +125,13 @@ 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
}
}
advertisement.CalculateExpire()
// prepare ad dir name