diff --git a/.claude/settings.local.json b/.claude/settings.local.json index cc5adf7..b88b128 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -18,7 +18,8 @@ "Bash(python -m pytest tests/test_backup.py -v)", "Bash(python -m pytest --tb=short -q)", "Bash(python -m pytest tests/test_wheeling.py -v)", - "WebFetch(domain:www.valottery.com)" + "WebFetch(domain:www.valottery.com)", + "Bash(pip install *)" ] } } diff --git a/core/fetcher.py b/core/fetcher.py index a41c1ee..81ddec1 100644 --- a/core/fetcher.py +++ b/core/fetcher.py @@ -280,19 +280,35 @@ def _fetch_va_lottery(game_name: str, source: str, url: str) -> dict: continue try: - numbers = [int(n.strip()) for n in parts[1].split(",") if n.strip()] + p1 = parts[1].strip() + p1_lower = p1.lower() + if p1_lower.startswith("day:"): + # Old twice-daily format: "Day: N1,...; Night: N1,..." + # Use Night draw only for consistency with modern single-draw records + if len(parts) >= 3 and "night:" in parts[2].lower(): + night_str = parts[2][parts[2].lower().find("night:") + 6:] + numbers = [int(n.strip()) for n in night_str.split(",") if n.strip()] + else: + continue + elif p1_lower.startswith("night:"): + # Night-only historical record + numbers = [int(n.strip()) for n in p1[p1_lower.find("night:") + 6:].split(",") if n.strip()] + else: + numbers = [int(n.strip()) for n in p1.split(",") if n.strip()] except ValueError as e: logger.warning("[FETCH] VA %s parse error %r: %s", source, line, e) continue bonus = None if len(parts) >= 3: - colon = parts[2].rfind(":") - if colon >= 0: - try: - bonus = int(parts[2][colon + 1:].strip()) - except ValueError: - pass + p_last = parts[-1].strip() + if "night:" not in p_last.lower() and "day:" not in p_last.lower(): + colon = p_last.rfind(":") + if colon >= 0: + try: + bonus = int(p_last[colon + 1:].strip()) + except ValueError: + pass result = insert_draw(game_id, draw_date, numbers, bonus=bonus, source=source) if result == "inserted": diff --git a/data/lottosight.db b/data/lottosight.db index 9de4260..37ad4ae 100644 Binary files a/data/lottosight.db and b/data/lottosight.db differ diff --git a/main.py b/main.py index bb03262..e28ff99 100644 --- a/main.py +++ b/main.py @@ -12,6 +12,12 @@ import threading import tkinter as tk from tkinter import ttk +try: + import truststore + truststore.inject_into_ssl() +except Exception: + pass # not installed or not needed on this platform + from apscheduler.schedulers.background import BackgroundScheduler from db.database import init_db diff --git a/requirements.txt b/requirements.txt index d8c15eb..acc5216 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,3 +4,4 @@ numpy>=1.26.0 matplotlib>=3.8.0 openpyxl>=3.1.0 APScheduler>=3.10.0 +truststore>=0.9.0