mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-04-10 13:02:59 +00:00
improve odds format for ticker
This commit is contained in:
@@ -109,7 +109,7 @@
|
||||
},
|
||||
"odds_ticker": {
|
||||
"enabled": true,
|
||||
"show_favorite_teams_only": false,
|
||||
"show_favorite_teams_only": true,
|
||||
"enabled_leagues": ["mlb"],
|
||||
"update_interval": 3600,
|
||||
"scroll_speed": 2,
|
||||
|
||||
@@ -28,7 +28,7 @@ class OddsManager:
|
||||
try:
|
||||
url = f"{self.base_url}/{sport}/leagues/{league}/events/{event_id}/competitions/{event_id}/odds"
|
||||
self.logger.info(f"Requesting odds from URL: {url}")
|
||||
response = requests.get(url)
|
||||
response = requests.get(url, timeout=10)
|
||||
response.raise_for_status()
|
||||
raw_data = response.json()
|
||||
self.logger.debug(f"Received raw odds data from ESPN: {json.dumps(raw_data, indent=2)}")
|
||||
@@ -41,6 +41,8 @@ class OddsManager:
|
||||
self.logger.info(f"Saved odds data to cache for {cache_key}")
|
||||
else:
|
||||
self.logger.warning(f"No odds data extracted for {cache_key}")
|
||||
# Cache the fact that no odds are available to avoid repeated API calls
|
||||
self.cache_manager.save_cache(cache_key, {"no_odds": True})
|
||||
|
||||
return odds_data
|
||||
|
||||
|
||||
@@ -207,9 +207,15 @@ class OddsTickerManager:
|
||||
odds_data = self.odds_manager.get_odds(
|
||||
sport=sport,
|
||||
league=league,
|
||||
event_id=game_id
|
||||
event_id=game_id,
|
||||
update_interval_seconds=7200 # Cache for 2 hours instead of 1 hour
|
||||
)
|
||||
|
||||
# Include games even without odds data (but log it)
|
||||
if odds_data and odds_data.get('no_odds'):
|
||||
logger.debug(f"Game {game_id} has no odds data, but including in display")
|
||||
odds_data = None # Set to None so display shows just game info
|
||||
|
||||
game_data = {
|
||||
'id': game_id,
|
||||
'league': league_config['league'],
|
||||
@@ -321,12 +327,12 @@ class OddsTickerManager:
|
||||
|
||||
if away_logo:
|
||||
away_logo.thumbnail((logo_size, logo_size), Image.Resampling.LANCZOS)
|
||||
away_x = text_x - logo_size - 5
|
||||
away_x = int(text_x - logo_size - 5)
|
||||
image.paste(away_logo, (away_x, logo_y), away_logo)
|
||||
|
||||
if home_logo:
|
||||
home_logo.thumbnail((logo_size, logo_size), Image.Resampling.LANCZOS)
|
||||
home_x = text_x + text_width + 5
|
||||
home_x = int(text_x + text_width + 5)
|
||||
image.paste(home_logo, (home_x, logo_y), home_logo)
|
||||
|
||||
return image
|
||||
|
||||
Reference in New Issue
Block a user