mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-04-10 21:03:01 +00:00
odds error handling so it doesn't get stuck
This commit is contained in:
@@ -307,6 +307,12 @@ class OddsTickerManager:
|
||||
url = f"https://site.api.espn.com/apis/site/v2/sports/{sport}/{league}/scoreboard?dates={date}"
|
||||
logger.debug(f"Fetching {league} games from ESPN API for date: {date}")
|
||||
response = requests.get(url, timeout=10)
|
||||
|
||||
# Handle potential 400 error for MiLB, which seems to be an invalid endpoint
|
||||
if league == 'milb' and response.status_code == 400:
|
||||
logger.warning(f"Received a 400 Bad Request for MiLB on {date}. This league may no longer be supported by the API. Skipping.")
|
||||
continue # Skip to the next date or league
|
||||
|
||||
response.raise_for_status()
|
||||
data = response.json()
|
||||
for event in data.get('events', []):
|
||||
@@ -380,6 +386,8 @@ class OddsTickerManager:
|
||||
# Stop if we have enough games for the league (when not showing favorite teams only)
|
||||
if not self.show_favorite_teams_only and max_games_per_league and games_found >= max_games_per_league:
|
||||
break
|
||||
except requests.exceptions.HTTPError as http_err:
|
||||
logger.error(f"HTTP error occurred while fetching games for {league} on {date}: {http_err}")
|
||||
except Exception as e:
|
||||
logger.error(f"Error fetching games for {league_config.get('league', 'unknown')} on {date}: {e}", exc_info=True)
|
||||
if not self.show_favorite_teams_only and max_games_per_league and games_found >= max_games_per_league:
|
||||
|
||||
Reference in New Issue
Block a user