mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-04-11 05:13:01 +00:00
milb turn off test mode....
This commit is contained in:
@@ -510,11 +510,36 @@ class BaseMiLBManager:
|
||||
mapped_status = 'status_scheduled'
|
||||
mapped_status_state = 'pre'
|
||||
|
||||
# Extract scores with fallback logic
|
||||
away_score = game['away'].get('score')
|
||||
home_score = game['home'].get('score')
|
||||
|
||||
# Debug logging for score extraction
|
||||
self.logger.debug(f"Initial scores for {away_abbr} @ {home_abbr}: away={away_score}, home={home_score}")
|
||||
|
||||
# If scores are None or missing, try to get from linescore
|
||||
if away_score is None or home_score is None:
|
||||
linescore = game.get('linescore', {})
|
||||
if linescore:
|
||||
teams_in_linescore = linescore.get('teams', {})
|
||||
if away_score is None:
|
||||
away_score = teams_in_linescore.get('away', {}).get('runs', 0)
|
||||
self.logger.debug(f"Got away score from linescore: {away_score}")
|
||||
if home_score is None:
|
||||
home_score = teams_in_linescore.get('home', {}).get('runs', 0)
|
||||
self.logger.debug(f"Got home score from linescore: {home_score}")
|
||||
|
||||
# Final fallback to 0 if still None
|
||||
away_score = away_score if away_score is not None else 0
|
||||
home_score = home_score if home_score is not None else 0
|
||||
|
||||
self.logger.debug(f"Final scores for {away_abbr} @ {home_abbr}: away={away_score}, home={home_score}")
|
||||
|
||||
game_data = {
|
||||
'away_team': away_abbr,
|
||||
'home_team': home_abbr,
|
||||
'away_score': game['away']['score'],
|
||||
'home_score': game['home']['score'],
|
||||
'away_score': away_score,
|
||||
'home_score': home_score,
|
||||
'status': mapped_status,
|
||||
'status_state': mapped_status_state,
|
||||
'start_time': game['date'],
|
||||
@@ -539,9 +564,21 @@ class BaseMiLBManager:
|
||||
|
||||
# Overwrite score and inning data with more accurate live data from the live feed
|
||||
if linescore_live:
|
||||
game_data['away_score'] = linescore_live.get('teams', {}).get('away', {}).get('runs', game_data['away_score'])
|
||||
game_data['home_score'] = linescore_live.get('teams', {}).get('home', {}).get('runs', game_data['home_score'])
|
||||
game_data['inning'] = linescore_live.get('currentInning', game_data['inning'])
|
||||
# Extract scores from live feed with fallback
|
||||
away_runs = linescore_live.get('teams', {}).get('away', {}).get('runs')
|
||||
home_runs = linescore_live.get('teams', {}).get('home', {}).get('runs')
|
||||
|
||||
# Only update if we got valid scores from live feed
|
||||
if away_runs is not None:
|
||||
game_data['away_score'] = away_runs
|
||||
if home_runs is not None:
|
||||
game_data['home_score'] = home_runs
|
||||
|
||||
# Update inning info
|
||||
current_inning = linescore_live.get('currentInning')
|
||||
if current_inning is not None:
|
||||
game_data['inning'] = current_inning
|
||||
|
||||
inning_state_live = linescore_live.get('inningState', '').lower()
|
||||
if inning_state_live:
|
||||
game_data['inning_half'] = 'bottom' if 'bottom' in inning_state_live else 'top'
|
||||
|
||||
Reference in New Issue
Block a user