"""Anime, series and file hosting providers configuration"""

ANIME_PROVIDERS = {
    "anime-sama": {
        "name": "Anime-Sama",
        "domains": [
            "anime-sama.to",
            "www.anime-sama.to",
            "anime-sama.tv",
            "www.anime-sama.tv",
            "anime-sama.si",
            "www.anime-sama.si",
            "anime-sama.org",
            "anime-sama.store",
            "anime-sama.eu",
        ],
        "url_pattern": "https://anime-sama.to/catalogue/{anime}/saison{season}/{lang}/",
        "icon": "🎬",
        "color": "#00d9ff",
    },
    "anime-ultime": {
        "name": "Anime-Ultime",
        "domains": ["anime-ultime.net", "anime-ultime.com", "www.anime-ultime.net"],
        "url_pattern": "https://www.anime-ultime.net/info-{id}-{slug}",
        "icon": "▶️",
        "color": "#00ff88",
    },
    "neko-sama": {
        "name": "Neko-Sama",
        "domains": ["neko-sama.fr", "nekosama.fr", "www.neko-sama.fr"],
        "url_pattern": "https://neko-sama.fr/anime/{slug}",
        "icon": "🐱",
        "color": "#ff6b6b",
    },
    "vostfree": {
        "name": "Vostfree",
        "domains": ["vostfree.tv", "www.vostfree.tv"],
        "url_pattern": "https://vostfree.tv/anime/{slug}",
        "icon": "📺",
        "color": "#ffd93d",
    },
    "french-manga": {
        "name": "French-Manga",
        "domains": [
            "french-manga.net",
            "w16.french-manga.net",
            "w15.french-manga.net",
            "www.french-manga.net",
        ],
        "url_pattern": "https://w16.french-manga.net/{slug}.html",
        "icon": "🇫🇷",
        "color": "#ff7675",
    },
}

SERIES_PROVIDERS = {
    "fs7": {
        "name": "French Stream",
        "domains": [
            "fs7.lol",
            "www.fs7.lol",
            "french-stream.tv",
            "www.french-stream.tv",
            "fs7.com",
            "fs7.net",
            "fs7.org",
            "fs7.cc",
            "fs7.co",
            "french-stream.com",
            "french-stream.net",
        ],
        "url_pattern": "https://fs7.lol/s-tv/{slug}.html",
        "icon": "🎬",
        "color": "#ff6b9d",
    },
    "zonetelechargement": {
        "name": "Zone-Telechargement",
        "domains": [
            "zone-telechargement.golf",
            "zone-telechargement.cam",
            "zone-telechargement.net",
            "zone-telechargement.org",
            "zone-telechargement.blue",
            "zone-telechargement.lol",
            "zone-telechargement.work",
            "zone-telechargement.ws",
            "www.zone-telechargement.golf",
            "www.zone-telechargement.cam",
        ],
        "url_pattern": "https://zone-telechargement.golf/index.php?do=search",
        "icon": "⬇️",
        "color": "#00d9ff",
    },
}

FILE_HOSTS = {
    "1fichier": {
        "name": "1fichier",
        "domains": ["1fichier.com", "1fichier.fr"],
        "icon": "📁",
        "color": "#4ecdc4",
    },
    "uptobox": {
        "name": "Uptobox",
        "domains": ["uptobox.com", "uptobox.fr"],
        "icon": "📦",
        "color": "#45b7d1",
    },
    "doodstream": {
        "name": "Doodstream",
        "domains": [
            "doodstream.com",
            "dood.stream",
            "dood.to",
            "dood.lol",
            "dood.cx",
            "dood.so",
            "dood.watch",
            "dood.sh",
        ],
        "icon": "🎥",
        "color": "#f7b731",
    },
    "rapidfile": {
        "name": "Rapidfile",
        "domains": ["rapidfile.net", "rapidfile.com"],
        "icon": "⚡",
        "color": "#ff6b6b",
    },
    "vidmoly": {
        "name": "VidMoly",
        "domains": ["vidmoly.to", "vidmoly.org", "vidmoly.biz"],
        "icon": "🎬",
        "color": "#a29bfe",
    },
    "sendvid": {
        "name": "SendVid",
        "domains": ["sendvid.com", "sendvid.io"],
        "icon": "📤",
        "color": "#fd79a8",
    },
    "sibnet": {
        "name": "Sibnet",
        "domains": ["sibnet.ru", "video.sibnet.ru"],
        "icon": "🎞️",
        "color": "#00cec9",
    },
    "lpayer": {
        "name": "Lplayer",
        "domains": ["lpayer.embed4me.com", "lpayer.com", "lplayer.fr"],
        "icon": "▶️",
        "color": "#e17055",
    },
    "vidzy": {
        "name": "Vidzy",
        "domains": ["vidzy.com", "vidzy.net", "www.vidzy.com"],
        "icon": "🎞️",
        "color": "#74b9ff",
    },
    "luluv": {
        "name": "LuLuvid",
        "domains": ["luluv.com", "luluvid.com", "www.luluv.com", "www.luluvid.com"],
        "icon": "🎬",
        "color": "#a29bfe",
    },
    "uqload": {
        "name": "Uqload",
        "domains": ["uqload.bz", "uqload.com", "www.uqload.bz", "www.uqload.com"],
        "icon": "📺",
        "color": "#fd79a8",
    },
    "smoothpre": {
        "name": "Smoothpre",
        "domains": ["smoothpre.com", "www.smoothpre.com"],
        "icon": "🎬",
        "color": "#a29bfe",
    },
}


def get_all_providers():
    """Get all supported providers (anime + series + file hosts)"""
    return {**ANIME_PROVIDERS, **SERIES_PROVIDERS, **FILE_HOSTS}


def get_anime_providers():
    """Get all anime streaming providers"""
    return ANIME_PROVIDERS


def get_series_providers():
    """Get all series streaming providers"""
    return SERIES_PROVIDERS


def get_file_hosts():
    """Get all file hosting providers"""
    return FILE_HOSTS


def detect_provider_from_url(url: str) -> str | None:
    """Detect which provider can handle the given URL"""
    url_lower = url.lower()

    for provider_id, provider in get_all_providers().items():
        for domain in provider["domains"]:
            if domain in url_lower:
                return provider_id

    return None
