From 9ba76b56d73d44045144b1908a90419b40e6f3a2 Mon Sep 17 00:00:00 2001 From: Alex Resnick Date: Sun, 5 Oct 2025 14:17:49 -0500 Subject: [PATCH] Update Football display. Add End of Period text and long down distance for larger screens (#101) Co-authored-by: Alex Resnick --- src/base_classes/football.py | 11 +++++++++-- src/base_classes/hockey.py | 6 +----- src/base_classes/sports.py | 1 + 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/base_classes/football.py b/src/base_classes/football.py index 3aca6c9a..a905bb02 100644 --- a/src/base_classes/football.py +++ b/src/base_classes/football.py @@ -27,6 +27,7 @@ class Football(SportsCore): # --- Football Specific Details (Likely same for NFL/NCAAFB) --- down_distance_text = "" + down_distance_text_long = "" possession_indicator = None # Default to None scoring_event = "" # Track scoring events home_timeouts = 0 @@ -37,7 +38,7 @@ class Football(SportsCore): if situation and status["type"]["state"] == "in": # down = situation.get("down") down_distance_text = situation.get("shortDownDistanceText") - # long_text = situation.get("downDistanceText") + down_distance_text_long = situation.get("downDistanceText") # distance = situation.get("distance") # Detect scoring events from status detail @@ -97,6 +98,7 @@ class Football(SportsCore): "home_timeouts": home_timeouts, "away_timeouts": away_timeouts, "down_distance_text": down_distance_text, # Added Down/Distance + "down_distance_text_long": down_distance_text_long, "is_redzone": is_redzone, "possession": posession, # ID of team with possession "possession_indicator": possession_indicator, # Added for easy home/away check @@ -203,7 +205,10 @@ class FootballLive(Football, SportsLive): # Period/Quarter and Clock (Top center) period_clock_text = f"{game.get('period_text', '')} {game.get('clock', '')}".strip() - if game.get("is_halftime"): period_clock_text = "Halftime" # Override for halftime + if game.get("is_halftime"): \ + period_clock_text = "Halftime" # Override for halftime + elif game.get("is_period_break"): + period_clock_text = game.get("status_text", "Period Break") status_width = draw_overlay.textlength(period_clock_text, font=self.fonts['time']) status_x = (self.display_width - status_width) // 2 @@ -213,6 +218,8 @@ class FootballLive(Football, SportsLive): # Down & Distance or Scoring Event (Below Period/Clock) scoring_event = game.get("scoring_event", "") down_distance = game.get("down_distance_text", "") + if self.display_width > 128: + down_distance = game.get("down_distance_text_long", "") # Show scoring event if detected, otherwise show down & distance if scoring_event and game.get("is_live"): diff --git a/src/base_classes/hockey.py b/src/base_classes/hockey.py index 7cfd2770..078ef3d4 100644 --- a/src/base_classes/hockey.py +++ b/src/base_classes/hockey.py @@ -75,7 +75,6 @@ class Hockey(SportsCore): home_shots = 0 away_shots = 0 - status_short = "" if home_team_saves_per > 0: away_shots = round(home_team_saves / home_team_saves_per) if away_team_saves_per > 0: @@ -84,7 +83,6 @@ class Hockey(SportsCore): if situation and status["type"]["state"] == "in": # Detect scoring events from status detail # status_detail = status["type"].get("detail", "") - status_short = status["type"].get("shortDetail", "") powerplay = situation.get("isPowerPlay", False) penalties = situation.get("penalties", "") @@ -115,8 +113,6 @@ class Hockey(SportsCore): "penalties": penalties, "home_shots": home_shots, "away_shots": away_shots, - "is_period_break": status["type"]["name"] == "STATUS_END_PERIOD", - "status_short": status_short, } ) @@ -229,7 +225,7 @@ class HockeyLive(Hockey, SportsLive): f"{game.get('period_text', '')} {game.get('clock', '')}".strip() ) if game.get("is_period_break"): - period_clock_text = game.get("status_short", "Period Break") + period_clock_text = game.get("status_text", "Period Break") status_width = draw_overlay.textlength( period_clock_text, font=self.fonts["time"] diff --git a/src/base_classes/sports.py b/src/base_classes/sports.py index 0dd2484f..02c15b9b 100644 --- a/src/base_classes/sports.py +++ b/src/base_classes/sports.py @@ -464,6 +464,7 @@ class SportsCore(ABC): "is_upcoming": (status["type"]["state"] == "pre" or status["type"]["name"].lower() in ['scheduled', 'pre-game', 'status_scheduled']), "is_halftime": status["type"]["state"] == "halftime" or status["type"]["name"] == "STATUS_HALFTIME", # Added halftime check + "is_period_break": status["type"]["name"] == "STATUS_END_PERIOD", # Added Period Break check "home_abbr": home_abbr, "home_id": home_team["id"], "home_score": home_team.get("score", "0"),