From 320dccf19c6bf8f2e76a79e336b730f07c40d861 Mon Sep 17 00:00:00 2001 From: Chuck <33324927+ChuckBuilds@users.noreply.github.com> Date: Sun, 20 Jul 2025 17:36:59 -0500 Subject: [PATCH] mlb tester --- config/config.json | 8 +++--- test_mlb_api.py | 69 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 4 deletions(-) create mode 100644 test_mlb_api.py diff --git a/config/config.json b/config/config.json index c68b1bcf..6a54ae35 100644 --- a/config/config.json +++ b/config/config.json @@ -110,7 +110,7 @@ "odds_ticker": { "enabled": true, "show_favorite_teams_only": false, - "enabled_leagues": ["nfl", "nba", "mlb", "ncaa_fb"], + "enabled_leagues": ["mlb"], "update_interval": 3600, "scroll_speed": 2, "scroll_delay": 0.05, @@ -142,7 +142,7 @@ } }, "nba_scoreboard": { - "enabled": false, + "enabled": true, "show_odds": false, "test_mode": false, "update_interval_seconds": 3600, @@ -161,7 +161,7 @@ } }, "nfl_scoreboard": { - "enabled": false, + "enabled": true, "show_odds": false, "test_mode": false, "update_interval_seconds": 3600, @@ -179,7 +179,7 @@ } }, "ncaa_fb_scoreboard": { - "enabled": false, + "enabled": true, "show_odds": false, "test_mode": false, "update_interval_seconds": 3600, diff --git a/test_mlb_api.py b/test_mlb_api.py new file mode 100644 index 00000000..4fd1d954 --- /dev/null +++ b/test_mlb_api.py @@ -0,0 +1,69 @@ +#!/usr/bin/env python3 +""" +Test script to check MLB API directly +""" + +import requests +import json +from datetime import datetime, timedelta, timezone + +def test_mlb_api(): + """Test the MLB API directly to see what games are available.""" + print("Testing MLB API directly...") + + # Get dates for the next 7 days + now = datetime.now(timezone.utc) + dates = [] + for i in range(8): # Today + 7 days + date = now + timedelta(days=i) + dates.append(date.strftime("%Y%m%d")) + + print(f"Checking dates: {dates}") + + for date in dates: + try: + url = f"https://site.api.espn.com/apis/site/v2/sports/baseball/mlb/scoreboard?dates={date}" + print(f"\nFetching MLB games for date: {date}") + print(f"URL: {url}") + + response = requests.get(url, timeout=10) + response.raise_for_status() + + data = response.json() + events = data.get('events', []) + + print(f"Found {len(events)} events for MLB on {date}") + + for event in events: + game_id = event['id'] + status = event['status']['type']['name'].lower() + game_time = datetime.fromisoformat(event['date'].replace('Z', '+00:00')) + + print(f" Game {game_id}:") + print(f" Status: {status}") + print(f" Time: {game_time}") + + if status in ['scheduled', 'pre-game']: + # Get team information + competitors = event['competitions'][0]['competitors'] + home_team = next(c for c in competitors if c['homeAway'] == 'home') + away_team = next(c for c in competitors if c['homeAway'] == 'away') + + home_abbr = home_team['team']['abbreviation'] + away_abbr = away_team['team']['abbreviation'] + + print(f" Teams: {away_abbr} @ {home_abbr}") + + # Check if it's in the next 7 days + if now <= game_time <= now + timedelta(days=7): + print(f" ✅ IN RANGE (next 7 days)") + else: + print(f" ❌ OUT OF RANGE") + else: + print(f" ❌ Status '{status}' - not upcoming") + + except Exception as e: + print(f"Error fetching MLB games for date {date}: {e}") + +if __name__ == "__main__": + test_mlb_api() \ No newline at end of file