import requests
import concurrent.futures
from datetime import datetime, timedelta
import urllib3

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

# We want to search around known Sky Sport IDs
# Known IDs: 9100, 9113, 11237, 9103, 9093, 9096, 11387 (dead)
# Let's search 9000-9200 and 11000-11500

ranges = list(range(9000, 9200)) + list(range(11000, 11500))

def check_id(channel_id):
    url = f"https://apid.sky.it/gtv/v1/events?from=2026-06-02T00:00:00Z&to=2026-06-03T00:00:00Z&pageSize=99&pageNum=0&env=DTH&channels={channel_id}"
    try:
        r = requests.get(url, headers={'User-Agent': 'Mozilla/5.0'}, timeout=5, verify=False)
        if r.status_code == 200:
            events = r.json().get('events', [])
            if events:
                for e in events:
                    title = e.get('eventTitle', '').lower()
                    ch = e.get('channel', {}).get('name', '').lower()
                    if 'basket' in title or 'basket' in ch or 'nba' in title or 'nba' in ch:
                        return f"FOUND BASKET/NBA in ID {channel_id}: {ch} - {title}"
                # If it's a sports channel, print it to see
                ch_name = events[0].get('channel', {}).get('name', '')
                if 'Sport' in ch_name or 'Basket' in ch_name:
                    return f"ID {channel_id}: {ch_name} ({len(events)} events)"
    except Exception as e:
        pass
    return None

with concurrent.futures.ThreadPoolExecutor(max_workers=20) as executor:
    results = executor.map(check_id, ranges)
    for res in results:
        if res:
            print(res)
