Adding NFL Scores (#3)
- Pre-game: No scores will be shown (scores are 0-0) - Live games: Current scores will display next to team names - Completed games: Final scores will be shown Co-authored-by: Eduardo Figueroa <eduardo_figueroa@ucsb.edu> Reviewed-on: https://codeberg.org/edfig/RosterHash/pulls/3
This commit is contained in:
parent
871bfde713
commit
763277ca8a
3 changed files with 27 additions and 4 deletions
|
|
@ -148,16 +148,23 @@ class ESPNAPI:
|
||||||
|
|
||||||
home_team = None
|
home_team = None
|
||||||
away_team = None
|
away_team = None
|
||||||
|
home_score = None
|
||||||
|
away_score = None
|
||||||
|
|
||||||
# Identify home and away teams
|
# Identify home and away teams and extract scores
|
||||||
for comp in competitors:
|
for comp in competitors:
|
||||||
team_abbrev = comp['team']['abbreviation']
|
team_abbrev = comp['team']['abbreviation']
|
||||||
# Normalize team abbreviation to match Sleeper format
|
# Normalize team abbreviation to match Sleeper format
|
||||||
normalized_team = self.normalize_team_abbreviation(team_abbrev)
|
normalized_team = self.normalize_team_abbreviation(team_abbrev)
|
||||||
|
# Get score if available
|
||||||
|
score = comp.get('score')
|
||||||
|
|
||||||
if comp['homeAway'] == 'home':
|
if comp['homeAway'] == 'home':
|
||||||
home_team = normalized_team
|
home_team = normalized_team
|
||||||
|
home_score = score
|
||||||
else:
|
else:
|
||||||
away_team = normalized_team
|
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)
|
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}",
|
'time': f"{game_date_local.strftime('%I:%M %p')} {tz_abbr}",
|
||||||
'home_team': home_team,
|
'home_team': home_team,
|
||||||
'away_team': away_team,
|
'away_team': away_team,
|
||||||
|
'home_score': home_score,
|
||||||
|
'away_score': away_score,
|
||||||
'teams': [home_team, away_team],
|
'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_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,
|
'is_live': is_live,
|
||||||
|
|
|
||||||
|
|
@ -426,6 +426,14 @@
|
||||||
color: var(--text-primary);
|
color: var(--text-primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.nfl-score {
|
||||||
|
color: var(--accent);
|
||||||
|
font-weight: 700;
|
||||||
|
font-size: 15px;
|
||||||
|
min-width: 20px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
.at {
|
.at {
|
||||||
color: var(--text-muted);
|
color: var(--text-muted);
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
|
|
|
||||||
|
|
@ -132,7 +132,13 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="matchup">
|
<div class="matchup">
|
||||||
<span class="away-team">{{ game.away_team }}</span>
|
<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>
|
<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>
|
<span class="home-team">{{ game.home_team }}</span>
|
||||||
</div>
|
</div>
|
||||||
<span class="game-collapse-indicator">{% if game.is_past and not game.is_live %}▶{% else %}▼{% endif %}</span>
|
<span class="game-collapse-indicator">{% if game.is_past and not game.is_live %}▶{% else %}▼{% endif %}</span>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue