import requests
import time
epoch_start = int(time.time() * 1000)
epoch_end = epoch_start + 3600000 * 24

test_callsigns = [
    "C1", "C2", "C3", "C4", "C5", "C6", "C7", "C8", "C9",
    "I1", "I2", "I3", "I4", "I5", "I6", "I7", "I8", "I9",
    "B1", "B2", "B3", "B4", "B5", "B6", "B7", "B8", "B9",
    "R1", "R2", "R3", "R4", "R5", "R6",
    "KA", "KB", "KC", "KD", "KE", "KF", "KG", "KH", "KI", "KJ", "KQ",
    "LA", "LB", "LC", "LD", "LE", "LF", "LT",
    "FU", "M1", "M2", "M3",
    "34",
    "E1", "E2"
]

for callsign in test_callsigns:
    url = f"https://api-ott-prod-fe.mediaset.net/PROD/play/feed/allListingFeedEpg/v2.0?byListingTime={epoch_start}~{epoch_end}&byCallSign={callsign}"
    try:
        res = requests.get(url, headers={'User-Agent': 'Mozilla/5.0'}).json()
        entries = res.get('response', {}).get('entries', [])
        if entries and entries[0].get('listings'):
            title = entries[0]['listings'][0].get('mediasetlisting$epgTitle', '?')
            print(f"FOUND: {callsign} -> {title}")
    except Exception as e:
        pass
