import requests, time
from concurrent.futures import ThreadPoolExecutor

epoch = int(time.time() * 1000)
url_template = f"https://api-ott-prod-fe.mediaset.net/PROD/play/feed/allListingFeedEpg/v2.0?byListingTime={epoch}~{epoch+86400000}&byCallSign="

chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
callsigns = [a+b for a in chars for b in chars]

def check(call):
    try:
        r = requests.get(url_template + call, headers={'User-Agent': 'Mozilla/5.0'}, timeout=3)
        if r.ok:
            entries = r.json().get('response', {}).get('entries', [])
            if entries and entries[0].get('listings'):
                title = entries[0]['listings'][0].get('mediasetlisting$epgTitle') or entries[0]['listings'][0].get('description') or '?'
                return f"{call} -> {title}"
    except:
        pass
    return None

with ThreadPoolExecutor(max_workers=50) as ex:
    results = ex.map(check, callsigns)

for res in results:
    if res:
        print(res)
