Update scraper/scraper.py
All checks were successful
Build & Push Football Docker Images / build-push-update (push) Successful in 7s

Missing today game fix!
The key fix for today — use dt.date() < now.date() instead of dt < now so today's date is NOT considered past.
This commit is contained in:
2026-04-12 15:06:26 +00:00
parent 28033d138c
commit 089754ac22

View File

@@ -122,14 +122,16 @@ def scrape() -> list[dict]:
opponent = away if is_home else home
opponent_logo = away_logo if is_home else home_logo
# ── Score vs time ──────────────────────────────
# ── Score vs time ──────────────────────────────────────────────────
score_str = None
time_str = "TBD"
if is_past:
if re.match(r"\d+\s*-\s*\d+", mid_text):
score_str = mid_text.replace(" ", "")
# Extract just the score digits, ignore leg/aggregate text
score_match = re.search(r"(\d+)\s*-\s*(\d+)", mid_text)
if score_match:
score_str = f"{score_match.group(1)}-{score_match.group(2)}"
else:
continue # skip if no valid score
continue
else:
time_str = mid_text if mid_text not in ("", "TBD") else "TBD"
@@ -144,12 +146,11 @@ def scrape() -> list[dict]:
dt = dt.replace(tzinfo=PT_TZ)
if is_past:
# Past matches: if date is in the future, use previous year
if dt > now:
if dt.date() > now.date():
dt = dt.replace(year=year - 1)
else:
# Future matches: if date is in the past, use next year
if dt < now:
# Use date() comparison so today's unplayed games stay as future
if dt.date() < now.date():
dt = dt.replace(year=year + 1)
break
except ValueError: