Adding NFL Scores

This commit is contained in:
Eduardo Figueroa 2025-10-29 16:02:04 -07:00
parent 871bfde713
commit b4ecd3888d
No known key found for this signature in database
GPG key ID: E4B7BBE6F7D53330
3 changed files with 27 additions and 4 deletions

View file

@ -139,25 +139,32 @@ class ESPNAPI:
# Extract team information and game status
competition = event['competitions'][0]
competitors = competition['competitors']
# Get game status information
status = competition.get('status', {})
game_state = status.get('type', {}).get('state', 'pre') # pre, in, post
is_live = game_state == 'in'
status_display = status.get('type', {}).get('name', 'Scheduled')
home_team = None
away_team = None
# Identify home and away teams
home_score = None
away_score = None
# Identify home and away teams and extract scores
for comp in competitors:
team_abbrev = comp['team']['abbreviation']
# Normalize team abbreviation to match Sleeper format
normalized_team = self.normalize_team_abbreviation(team_abbrev)
# Get score if available
score = comp.get('score')
if comp['homeAway'] == 'home':
home_team = normalized_team
home_score = score
else:
away_team = normalized_team
away_score = score
print(f"ESPN API: {away_team} @ {home_team} at {game_date_local.strftime('%I:%M %p')} {tz_abbr}", flush=True)
@ -170,6 +177,8 @@ class ESPNAPI:
'time': f"{game_date_local.strftime('%I:%M %p')} {tz_abbr}",
'home_team': home_team,
'away_team': away_team,
'home_score': home_score,
'away_score': away_score,
'teams': [home_team, away_team],
'is_past': game_date_local < (debug_current_time.astimezone(game_date_local.tzinfo) if debug_current_time else datetime.now(game_date_local.tzinfo)),
'is_live': is_live,

View file

@ -426,6 +426,14 @@
color: var(--text-primary);
}
.nfl-score {
color: var(--accent);
font-weight: 700;
font-size: 15px;
min-width: 20px;
text-align: center;
}
.at {
color: var(--text-muted);
font-size: 12px;

View file

@ -132,7 +132,13 @@
</div>
<div class="matchup">
<span class="away-team">{{ game.away_team }}</span>
{% if game.away_score is not none %}
<span class="nfl-score">{{ game.away_score }}</span>
{% endif %}
<span class="at">@</span>
{% if game.home_score is not none %}
<span class="nfl-score">{{ game.home_score }}</span>
{% endif %}
<span class="home-team">{{ game.home_team }}</span>
</div>
<span class="game-collapse-indicator">{% if game.is_past and not game.is_live %}▶{% else %}▼{% endif %}</span>