import sys
import os

sys.path.append(os.path.dirname(os.path.abspath(__file__)))
import config
from scratch_test_assets import get_asset_map

def run_all_channels():
    asset_map = get_asset_map()
    all_channels = []
    all_channels.extend(list(config.RAI_CHANNELS.values()))
    all_channels.extend(list(config.MEDIASET_CHANNELS.values()))
    all_channels.extend(list(config.SKY_CHANNELS.values()))
    
    missing = []
    
    ALIASES = {
        "italia_1": "italia_uno",
        "rai_sport_plus": "raisport",
        "rai_news_24": "rai_news",
        "20": "canale_20",
        "boing": "mediaset_boing",
        "tgcom24": "mediaset_tgcom24",
        "cine34": "cine_34",
        "twenty_seven": "mediaset_27",
        "sky_cinema_suspense": "sky_cinema_suspance",
        "sky_sport_formula1": "sky_sport_f1",
        "history": "sky_history",
        "mtv": "sky_mtv",
        "nickjr": "nick_jr"
    }

    for chan in all_channels:
        fmt = chan.lower().replace(" ", "_").replace("+", "plus")
        if "sky_sport_25" in fmt:
            fmt = "sky_sport"
        elif fmt == "sky_tv8" or fmt == "sky_tv8_hd":
            fmt = "tv8"
        
        fmt = ALIASES.get(fmt, fmt)
        
        if fmt in asset_map:
            img = asset_map[fmt]
        elif fmt.replace("_", "") in asset_map:
            img = asset_map[fmt.replace("_", "")]
        else:
            img = "NOT FOUND"
            missing.append(chan)
            
    print("\n--- MISSING ---")
    for m in missing:
        print(m)

run_all_channels()
