mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-04-10 13:02:59 +00:00
improve filtering on show_favorite_teams_only
This commit is contained in:
@@ -809,31 +809,28 @@ class MLBLiveManager(BaseMLBManager):
|
||||
}
|
||||
self.logger.info(f"[MLB Live] Filtered to {len(games)} games for favorite teams.")
|
||||
|
||||
# Find all live games involving favorite teams
|
||||
# Find all live games
|
||||
new_live_games = []
|
||||
for game in games.values():
|
||||
# Only process games that are actually in progress
|
||||
if game['status_state'] == 'in' and game['status'] == 'status_in_progress':
|
||||
if not self.favorite_teams or (
|
||||
game['home_team'] in self.favorite_teams or
|
||||
game['away_team'] in self.favorite_teams
|
||||
):
|
||||
self._fetch_odds(game)
|
||||
# Ensure scores are valid numbers
|
||||
try:
|
||||
game['home_score'] = int(game['home_score'])
|
||||
game['away_score'] = int(game['away_score'])
|
||||
new_live_games.append(game)
|
||||
except (ValueError, TypeError):
|
||||
self.logger.warning(f"Invalid score format for game {game['away_team']} @ {game['home_team']}")
|
||||
else:
|
||||
# Not in favorites-only mode, so add the game
|
||||
try:
|
||||
game['home_score'] = int(game['home_score'])
|
||||
game['away_score'] = int(game['away_score'])
|
||||
new_live_games.append(game)
|
||||
except (ValueError, TypeError):
|
||||
self.logger.warning(f"Invalid score format for game {game['away_team']} @ {game['home_team']}")
|
||||
# Check if this is a favorite team game
|
||||
is_favorite_game = (game['home_team'] in self.favorite_teams or
|
||||
game['away_team'] in self.favorite_teams)
|
||||
|
||||
# Only filter by favorite teams if show_favorite_teams_only is True
|
||||
if self.mlb_config.get("show_favorite_teams_only", False) and not is_favorite_game:
|
||||
self.logger.debug(f"[MLB Live] Skipping game {game['away_team']} @ {game['home_team']} - not a favorite team.")
|
||||
continue
|
||||
|
||||
self._fetch_odds(game)
|
||||
# Ensure scores are valid numbers
|
||||
try:
|
||||
game['home_score'] = int(game['home_score'])
|
||||
game['away_score'] = int(game['away_score'])
|
||||
new_live_games.append(game)
|
||||
except (ValueError, TypeError):
|
||||
self.logger.warning(f"Invalid score format for game {game['away_team']} @ {game['home_team']}")
|
||||
|
||||
# Only log if there's a change in games or enough time has passed
|
||||
should_log = (
|
||||
@@ -1201,7 +1198,8 @@ class MLBRecentManager(BaseMLBManager):
|
||||
self.logger.info(f"[MLB] Game time (UTC): {game_time}")
|
||||
self.logger.info(f"[MLB] Game status: {game['status']}, State: {game['status_state']}")
|
||||
|
||||
if not is_favorite_game:
|
||||
# Only filter by favorite teams if show_favorite_teams_only is True
|
||||
if self.mlb_config.get("show_favorite_teams_only", False) and not is_favorite_game:
|
||||
self.logger.debug(f"[MLB] Skipping game {game_id} - not a favorite team.")
|
||||
continue
|
||||
|
||||
|
||||
@@ -887,7 +887,9 @@ class NCAABaseballRecentManager(BaseNCAABaseballManager):
|
||||
if game_time.tzinfo is None: game_time = game_time.replace(tzinfo=timezone.utc)
|
||||
|
||||
is_favorite_game = (game['home_team'] in self.favorite_teams or game['away_team'] in self.favorite_teams)
|
||||
if not is_favorite_game: continue
|
||||
# Only filter by favorite teams if show_favorite_teams_only is True
|
||||
if self.ncaa_baseball_config.get("show_favorite_teams_only", False) and not is_favorite_game:
|
||||
continue
|
||||
|
||||
logger.info(f"[NCAABaseball] Checking favorite recent game: {game['away_team']} @ {game['home_team']}")
|
||||
logger.info(f"[NCAABaseball] Game time (UTC): {game_time}")
|
||||
@@ -983,7 +985,9 @@ class NCAABaseballUpcomingManager(BaseNCAABaseballManager):
|
||||
|
||||
for game in games.values():
|
||||
is_favorite_game = (game['home_team'] in self.favorite_teams or game['away_team'] in self.favorite_teams)
|
||||
if not is_favorite_game: continue
|
||||
# Only filter by favorite teams if show_favorite_teams_only is True
|
||||
if self.ncaa_baseball_config.get("show_favorite_teams_only", False) and not is_favorite_game:
|
||||
continue
|
||||
|
||||
game_time = datetime.fromisoformat(game['start_time'].replace('Z', '+00:00'))
|
||||
if game_time.tzinfo is None: game_time = game_time.replace(tzinfo=timezone.utc)
|
||||
|
||||
Reference in New Issue
Block a user