add channel logo for odds_ticker_manager

This commit is contained in:
Chuck
2025-07-22 11:49:29 -05:00
parent c141742b6a
commit f6441c0674
21 changed files with 18 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

@@ -259,6 +259,13 @@ class OddsTickerManager:
away_abbr = away_team['team']['abbreviation']
home_name = home_team['team'].get('name', home_abbr)
away_name = away_team['team'].get('name', away_abbr)
broadcast_info = ""
broadcasts = event.get('competitions', [{}])[0].get('broadcasts', [])
if broadcasts:
broadcast_info = broadcasts[0].get('media', {}).get('shortName', "")
logger.info(f"Found broadcast info for game {game_id}: {broadcast_info}")
# Only process favorite teams if enabled
if self.show_favorite_teams_only:
if not favorite_teams:
@@ -294,6 +301,7 @@ class OddsTickerManager:
'home_record': home_record,
'away_record': away_record,
'odds': odds_data if has_odds else None,
'broadcast_info': broadcast_info,
'logo_dir': league_config.get('logo_dir', f'assets/sports/{league.lower()}_logos')
}
all_games.append(game)
@@ -402,11 +410,14 @@ class OddsTickerManager:
# Get team logos
home_logo = self._get_team_logo(game['home_team'], game['logo_dir'])
away_logo = self._get_team_logo(game['away_team'], game['logo_dir'])
broadcast_logo = self._get_team_logo(game.get('broadcast_info', ''), 'assets/broadcast_logos')
if home_logo:
home_logo = home_logo.resize((logo_size, logo_size), Image.Resampling.LANCZOS)
if away_logo:
away_logo = away_logo.resize((logo_size, logo_size), Image.Resampling.LANCZOS)
if broadcast_logo:
broadcast_logo = broadcast_logo.resize((logo_size, logo_size), Image.Resampling.LANCZOS)
# Create a temporary draw object to measure text
temp_draw = ImageDraw.Draw(Image.new('RGB', (1, 1)))
@@ -445,6 +456,9 @@ class OddsTickerManager:
date_width = int(temp_draw.textlength(date_text, font=datetime_font))
time_width = int(temp_draw.textlength(time_text, font=datetime_font))
datetime_col_width = max(day_width, date_width, time_width)
if broadcast_logo:
datetime_col_width = max(datetime_col_width, broadcast_logo.width)
# Odds text
odds = game.get('odds') or {}
@@ -549,6 +563,10 @@ class OddsTickerManager:
draw.text((current_x, date_y), date_text, font=datetime_font, fill=(255, 255, 255))
draw.text((current_x, time_y), time_text, font=datetime_font, fill=(255, 255, 255))
if broadcast_logo:
broadcast_y = time_y + datetime_font_height + 2
image.paste(broadcast_logo, (int(current_x), broadcast_y), broadcast_logo if broadcast_logo.mode == 'RGBA' else None)
return image
def _create_ticker_image(self):