221 lines
7.9 KiB
Python
221 lines
7.9 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
WNBA schedule and stadium scrapers for SportsTime.
|
|
|
|
This module provides:
|
|
- WNBA team mappings (13 teams)
|
|
- WNBA stadium scrapers (hardcoded with coordinates)
|
|
- Multi-source fallback configurations
|
|
|
|
Note: Many WNBA teams share arenas with NBA or NHL teams.
|
|
Coordinates are cross-referenced from nba.py and nhl.py where applicable.
|
|
"""
|
|
|
|
from typing import Optional
|
|
|
|
import requests
|
|
|
|
# Support both direct execution and import from parent directory
|
|
try:
|
|
from core import (
|
|
Game,
|
|
Stadium,
|
|
ScraperSource,
|
|
StadiumScraperSource,
|
|
fetch_page,
|
|
scrape_with_fallback,
|
|
scrape_stadiums_with_fallback,
|
|
)
|
|
except ImportError:
|
|
from Scripts.core import (
|
|
Game,
|
|
Stadium,
|
|
ScraperSource,
|
|
StadiumScraperSource,
|
|
fetch_page,
|
|
scrape_with_fallback,
|
|
scrape_stadiums_with_fallback,
|
|
)
|
|
|
|
|
|
__all__ = [
|
|
# Team data
|
|
'WNBA_TEAMS',
|
|
# Stadium scrapers
|
|
'scrape_wnba_stadiums_hardcoded',
|
|
'scrape_wnba_stadiums',
|
|
# Source configurations
|
|
'WNBA_STADIUM_SOURCES',
|
|
# Convenience functions
|
|
'get_wnba_team_abbrev',
|
|
]
|
|
|
|
|
|
# =============================================================================
|
|
# TEAM MAPPINGS
|
|
# =============================================================================
|
|
|
|
WNBA_TEAMS = {
|
|
'ATL': {'name': 'Atlanta Dream', 'city': 'College Park', 'arena': 'Gateway Center Arena'},
|
|
'CHI': {'name': 'Chicago Sky', 'city': 'Chicago', 'arena': 'Wintrust Arena'},
|
|
'CON': {'name': 'Connecticut Sun', 'city': 'Uncasville', 'arena': 'Mohegan Sun Arena'},
|
|
'DAL': {'name': 'Dallas Wings', 'city': 'Arlington', 'arena': 'College Park Center'},
|
|
'GSV': {'name': 'Golden State Valkyries', 'city': 'San Francisco', 'arena': 'Chase Center'},
|
|
'IND': {'name': 'Indiana Fever', 'city': 'Indianapolis', 'arena': 'Gainbridge Fieldhouse'},
|
|
'LVA': {'name': 'Las Vegas Aces', 'city': 'Las Vegas', 'arena': 'Michelob Ultra Arena'},
|
|
'LA': {'name': 'Los Angeles Sparks', 'city': 'Los Angeles', 'arena': 'Crypto.com Arena'},
|
|
'MIN': {'name': 'Minnesota Lynx', 'city': 'Minneapolis', 'arena': 'Target Center'},
|
|
'NY': {'name': 'New York Liberty', 'city': 'Brooklyn', 'arena': 'Barclays Center'},
|
|
'PHO': {'name': 'Phoenix Mercury', 'city': 'Phoenix', 'arena': 'Footprint Center'},
|
|
'SEA': {'name': 'Seattle Storm', 'city': 'Seattle', 'arena': 'Climate Pledge Arena'},
|
|
'WAS': {'name': 'Washington Mystics', 'city': 'Washington', 'arena': 'Entertainment & Sports Arena'},
|
|
}
|
|
|
|
|
|
def get_wnba_team_abbrev(team_name: str) -> str:
|
|
"""Get WNBA team abbreviation from full name."""
|
|
for abbrev, info in WNBA_TEAMS.items():
|
|
if info['name'].lower() == team_name.lower():
|
|
return abbrev
|
|
if team_name.lower() in info['name'].lower():
|
|
return abbrev
|
|
|
|
# Return first 3 letters as fallback
|
|
return team_name[:3].upper()
|
|
|
|
|
|
# =============================================================================
|
|
# STADIUM SCRAPERS
|
|
# =============================================================================
|
|
|
|
def scrape_wnba_stadiums_hardcoded() -> list[Stadium]:
|
|
"""
|
|
Source 1: Hardcoded WNBA arenas with complete data.
|
|
All 13 WNBA arenas with capacity (WNBA configuration) and year_opened.
|
|
|
|
Shared arena coordinates are cross-referenced from NBA/NHL modules:
|
|
- Chase Center (shared with GSW Warriors)
|
|
- Gainbridge Fieldhouse (shared with IND Pacers)
|
|
- Crypto.com Arena (shared with LAL Lakers)
|
|
- Target Center (shared with MIN Timberwolves)
|
|
- Barclays Center (shared with BRK Nets)
|
|
- Footprint Center (shared with PHO Suns)
|
|
- Climate Pledge Arena (shared with SEA Kraken)
|
|
"""
|
|
wnba_arenas = {
|
|
# WNBA-specific arenas
|
|
'Gateway Center Arena': {
|
|
'city': 'College Park', 'state': 'GA',
|
|
'lat': 33.6343, 'lng': -84.4489,
|
|
'capacity': 3500, 'teams': ['ATL'], 'year_opened': 2018
|
|
},
|
|
'Wintrust Arena': {
|
|
'city': 'Chicago', 'state': 'IL',
|
|
'lat': 41.8514, 'lng': -87.6226,
|
|
'capacity': 10387, 'teams': ['CHI'], 'year_opened': 2017
|
|
},
|
|
'Mohegan Sun Arena': {
|
|
'city': 'Uncasville', 'state': 'CT',
|
|
'lat': 41.4933, 'lng': -72.0904,
|
|
'capacity': 10000, 'teams': ['CON'], 'year_opened': 2001
|
|
},
|
|
'College Park Center': {
|
|
'city': 'Arlington', 'state': 'TX',
|
|
'lat': 32.7319, 'lng': -97.1103,
|
|
'capacity': 7000, 'teams': ['DAL'], 'year_opened': 2012
|
|
},
|
|
'Michelob Ultra Arena': {
|
|
'city': 'Las Vegas', 'state': 'NV',
|
|
'lat': 36.0909, 'lng': -115.1750,
|
|
'capacity': 12000, 'teams': ['LVA'], 'year_opened': 2016
|
|
},
|
|
'Entertainment & Sports Arena': {
|
|
'city': 'Washington', 'state': 'DC',
|
|
'lat': 38.8720, 'lng': -76.9870,
|
|
'capacity': 4200, 'teams': ['WAS'], 'year_opened': 2018
|
|
},
|
|
# Shared arenas with NBA teams (coordinates from nba.py)
|
|
'Chase Center': {
|
|
'city': 'San Francisco', 'state': 'CA',
|
|
'lat': 37.7680, 'lng': -122.3879,
|
|
'capacity': 18064, 'teams': ['GSV'], 'year_opened': 2019
|
|
},
|
|
'Gainbridge Fieldhouse': {
|
|
'city': 'Indianapolis', 'state': 'IN',
|
|
'lat': 39.7640, 'lng': -86.1555,
|
|
'capacity': 17923, 'teams': ['IND'], 'year_opened': 1999
|
|
},
|
|
'Crypto.com Arena': {
|
|
'city': 'Los Angeles', 'state': 'CA',
|
|
'lat': 34.0430, 'lng': -118.2673,
|
|
'capacity': 19079, 'teams': ['LA'], 'year_opened': 1999
|
|
},
|
|
'Target Center': {
|
|
'city': 'Minneapolis', 'state': 'MN',
|
|
'lat': 44.9795, 'lng': -93.2761,
|
|
'capacity': 18978, 'teams': ['MIN'], 'year_opened': 1990
|
|
},
|
|
'Barclays Center': {
|
|
'city': 'Brooklyn', 'state': 'NY',
|
|
'lat': 40.6826, 'lng': -73.9754,
|
|
'capacity': 17732, 'teams': ['NY'], 'year_opened': 2012
|
|
},
|
|
'Footprint Center': {
|
|
'city': 'Phoenix', 'state': 'AZ',
|
|
'lat': 33.4457, 'lng': -112.0712,
|
|
'capacity': 17071, 'teams': ['PHO'], 'year_opened': 1992
|
|
},
|
|
# Shared arena with NHL team (coordinates from nhl.py)
|
|
'Climate Pledge Arena': {
|
|
'city': 'Seattle', 'state': 'WA',
|
|
'lat': 47.6220, 'lng': -122.3540,
|
|
'capacity': 17100, 'teams': ['SEA'], 'year_opened': 1962
|
|
},
|
|
}
|
|
|
|
stadiums = []
|
|
for name, info in wnba_arenas.items():
|
|
# Create normalized ID (f-strings can't have backslashes)
|
|
normalized_name = name.lower().replace(' ', '_').replace('&', 'and').replace('.', '').replace("'", '')
|
|
stadium_id = f"wnba_{normalized_name[:30]}"
|
|
stadium = Stadium(
|
|
id=stadium_id,
|
|
name=name,
|
|
city=info['city'],
|
|
state=info['state'],
|
|
latitude=info['lat'],
|
|
longitude=info['lng'],
|
|
capacity=info['capacity'],
|
|
sport='WNBA',
|
|
team_abbrevs=info['teams'],
|
|
source='wnba_hardcoded',
|
|
year_opened=info.get('year_opened')
|
|
)
|
|
stadiums.append(stadium)
|
|
|
|
return stadiums
|
|
|
|
|
|
def scrape_wnba_stadiums() -> list[Stadium]:
|
|
"""
|
|
Fetch WNBA arena data with multi-source fallback.
|
|
Hardcoded source is primary (has complete data).
|
|
"""
|
|
print("\nWNBA STADIUMS")
|
|
print("-" * 40)
|
|
|
|
sources = [
|
|
StadiumScraperSource('Hardcoded', scrape_wnba_stadiums_hardcoded, priority=1, min_venues=10),
|
|
]
|
|
|
|
return scrape_stadiums_with_fallback('WNBA', sources)
|
|
|
|
|
|
# =============================================================================
|
|
# SOURCE CONFIGURATIONS
|
|
# =============================================================================
|
|
|
|
WNBA_STADIUM_SOURCES = [
|
|
StadiumScraperSource('Hardcoded', scrape_wnba_stadiums_hardcoded, priority=1, min_venues=10),
|
|
]
|