mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-04-11 05:13:01 +00:00
Fix odds and more (#81)
* fix(odds): Resolve incorrect sport and league parameters in _fetch_odds calls - Fixed SportsCore._fetch_data() to call _fetch_odds(game) instead of _fetch_odds(game, sport_key, sport_key) - Updated _fetch_odds method signature to accept only game parameter - Added _fetch_odds_with_params helper method for sport-specific implementations - Updated sport-specific managers to use correct sport and league parameters: - NFL: football/nfl - NCAA Football: football/college-football - NCAA Hockey: hockey/mens-college-hockey - Ensures odds are fetched with correct ESPN API endpoints Fixes #79 * Fix odds and other things * update hockey * fix rankings * update imports * Fix Logo Cache * Add show_favorite_team_only attribute --------- Co-authored-by: ChuckBuilds <33324927+ChuckBuilds@users.noreply.github.com> Co-authored-by: Alex Resnick <adr8282@gmail.com>
This commit is contained in:
@@ -15,8 +15,8 @@ from src.odds_manager import OddsManager
|
||||
from src.background_data_service import get_background_service
|
||||
|
||||
# Import baseball and standard sports classes
|
||||
from .base_classes.baseball import Baseball, BaseballLive
|
||||
from .base_classes.sports import SportsRecent, SportsUpcoming
|
||||
from src.base_classes.baseball import Baseball, BaseballLive
|
||||
from src.base_classes.sports import SportsRecent, SportsUpcoming
|
||||
|
||||
# Import the API counter function from web interface
|
||||
try:
|
||||
@@ -40,7 +40,7 @@ class BaseMLBManager(Baseball):
|
||||
self.show_odds = self.mlb_config.get("show_odds", False)
|
||||
self.favorite_teams = self.mlb_config.get('favorite_teams', [])
|
||||
self.show_records = self.mlb_config.get('show_records', False)
|
||||
|
||||
self.league = "mlb"
|
||||
# Store reference to config instead of creating new ConfigManager
|
||||
self.config_manager = None # Not used in this class
|
||||
self.odds_manager = OddsManager(self.cache_manager, self.config_manager)
|
||||
@@ -83,58 +83,6 @@ class BaseMLBManager(Baseball):
|
||||
self.background_enabled = False
|
||||
self.logger.info("[MLB] Background service disabled")
|
||||
|
||||
def _fetch_odds(self, game: Dict) -> None:
|
||||
"""Fetch odds for a game and attach it to the game dictionary."""
|
||||
# Check if odds should be shown for this sport
|
||||
if not self.show_odds:
|
||||
return
|
||||
|
||||
# Check if we should only fetch for favorite teams
|
||||
is_favorites_only = self.mlb_config.get("show_favorite_teams_only", False)
|
||||
if is_favorites_only:
|
||||
home_team = game.get('home_team')
|
||||
away_team = game.get('away_team')
|
||||
if not (home_team in self.favorite_teams or away_team in self.favorite_teams):
|
||||
self.logger.debug(f"Skipping odds fetch for non-favorite game in favorites-only mode: {away_team}@{home_team}")
|
||||
return
|
||||
|
||||
self.logger.debug(f"Proceeding with odds fetch for game: {game.get('id', 'N/A')}")
|
||||
|
||||
# Skip if odds are already attached to this game
|
||||
if 'odds' in game and game['odds']:
|
||||
return
|
||||
|
||||
try:
|
||||
game_id = game.get('id', 'N/A')
|
||||
self.logger.info(f"Requesting odds for game ID: {game_id}")
|
||||
|
||||
odds_data = self.odds_manager.get_odds(
|
||||
sport="baseball",
|
||||
league="mlb",
|
||||
event_id=game_id
|
||||
)
|
||||
if odds_data:
|
||||
game['odds'] = odds_data
|
||||
self.logger.info(f"Successfully attached odds to game {game_id}")
|
||||
|
||||
# Check if the odds data has any non-null values
|
||||
has_odds = False
|
||||
if odds_data.get('spread') is not None:
|
||||
has_odds = True
|
||||
if odds_data.get('home_team_odds', {}).get('spread_odds') is not None:
|
||||
has_odds = True
|
||||
if odds_data.get('away_team_odds', {}).get('spread_odds') is not None:
|
||||
has_odds = True
|
||||
|
||||
if not has_odds:
|
||||
self.logger.warning(f"Odds data returned for game {game_id} but all values are null")
|
||||
else:
|
||||
self.logger.info(f"Found actual odds data for game {game_id}")
|
||||
else:
|
||||
self.logger.warning(f"No odds data returned for game {game_id}")
|
||||
except Exception as e:
|
||||
self.logger.error(f"Error fetching odds for game {game.get('id', 'N/A')}: {e}")
|
||||
|
||||
def _get_team_logo(self, team_abbr: str) -> Optional[Image.Image]:
|
||||
"""Get team logo from the configured directory."""
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user