feat: add Django web app, CloudKit sync, dashboard, and game_datetime_utc export

Adds the full Django application layer on top of sportstime_parser:
- core: Sport, Team, Stadium, Game models with aliases and league structure
- scraper: orchestration engine, adapter, job management, Celery tasks
- cloudkit: CloudKit sync client, sync state tracking, sync jobs
- dashboard: staff dashboard for monitoring scrapers, sync, review queue
- notifications: email reports for scrape/sync results
- Docker setup for deployment (Dockerfile, docker-compose, entrypoint)

Game exports now use game_datetime_utc (ISO 8601 UTC) instead of
venue-local date+time strings, matching the canonical format used
by the iOS app.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Trey t
2026-02-19 14:04:27 -06:00
parent 4353d5943c
commit 63acf7accb
114 changed files with 13070 additions and 887 deletions

View File

@@ -2,6 +2,7 @@
from datetime import datetime, date
from typing import Optional
from zoneinfo import ZoneInfo
from bs4 import BeautifulSoup
from .base import BaseScraper, RawGameData, ScrapeResult
@@ -33,7 +34,12 @@ class NFLScraper(BaseScraper):
Sources (in priority order):
1. ESPN API - Most reliable for NFL
2. Pro-Football-Reference - Complete historical data
3. CBS Sports - Backup option
3. CBS Sports - Backup option (not implemented)
Source Timezones:
- espn: UTC - ISO 8601 format with "Z" suffix
- pro_football_reference: Eastern Time (ET) - times displayed as "8:20PM"
- cbs: Not implemented
"""
def __init__(self, season: int, **kwargs):
@@ -56,7 +62,7 @@ class NFLScraper(BaseScraper):
if source == "espn":
week = kwargs.get("week", 1)
season_type = kwargs.get("season_type", 2) # 1=preseason, 2=regular, 3=postseason
return f"https://site.api.espn.com/apis/site/v2/sports/football/nfl/scoreboard?seasontype={season_type}&week={week}"
return f"https://site.api.espn.com/apis/site/v2/sports/football/nfl/scoreboard?season={self.season}&seasontype={season_type}&week={week}"
elif source == "pro_football_reference":
return f"https://www.pro-football-reference.com/years/{self.season}/games.htm"
@@ -323,6 +329,25 @@ class NFLScraper(BaseScraper):
except ValueError:
return None
# Get game start time (format: "8:20PM" or "1:00PM") - times are in ET
time_cell = row.find("td", {"data-stat": "gametime"})
if time_cell:
time_text = time_cell.get_text(strip=True)
if time_text:
try:
# Parse time like "8:20PM" or "1:00PM"
# Normalize: "8:20PM" -> "8:20 PM"
time_normalized = time_text.replace("PM", " PM").replace("AM", " AM")
game_time = datetime.strptime(time_normalized, "%I:%M %p")
# Combine date and time with ET timezone (Pro-Football-Reference uses ET)
game_date = game_date.replace(
hour=game_time.hour,
minute=game_time.minute,
tzinfo=ZoneInfo("America/New_York"),
)
except ValueError:
self._logger.debug(f"Could not parse time: {time_text}, using midnight")
# Get teams
winner_cell = row.find("td", {"data-stat": "winner"})
loser_cell = row.find("td", {"data-stat": "loser"})
@@ -566,6 +591,7 @@ class NFLScraper(BaseScraper):
country=info.country,
latitude=info.latitude,
longitude=info.longitude,
timezone=info.timezone,
surface="turf", # Many NFL stadiums
roof_type="open", # Most outdoor
)