diff --git a/scraper/scraper.py b/scraper/scraper.py index fe4c001..6abd755 100644 --- a/scraper/scraper.py +++ b/scraper/scraper.py @@ -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" @@ -142,14 +144,13 @@ def scrape() -> list[dict]: try: dt = datetime.strptime(f"{date_text} {year}", fmt) 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: