"""
Root routes for Ohm Stream Downloader API.
"""

from fastapi import APIRouter

from app import providers

router = APIRouter(prefix="", tags=["root"])


@router.get("/")
async def root():
    """Root endpoint with API information"""
    return {
        "message": "Ohm Stream Downloader API",
        "status": "running",
        "version": "2.2",
        "endpoints": {
            "POST /api/download": "Start a new download",
            "GET /api/downloads": "List all downloads",
            "GET /api/download/{task_id}": "Get download status",
            "POST /api/download/{task_id}/pause": "Pause a download",
            "POST /api/download/{task_id}/resume": "Resume a download",
            "DELETE /api/download/{task_id}": "Cancel a download",
            "GET /api/providers": "List all supported providers",
            "GET /api/anime/search": "Search anime across all providers",
            "GET /api/anime/metadata": "Get detailed anime metadata",
            "GET /api/anime/episodes": "Get episode list for an anime",
            "POST /api/anime/download-season": "Download all episodes of a season",
            "GET /api/favorites": "List all favorite anime",
            "POST /api/favorites": "Add anime to favorites",
            "DELETE /api/favorites/{anime_id}": "Remove from favorites",
            "GET /api/favorites/{anime_id}": "Get favorite anime details",
            "GET /api/favorites/stats": "Get favorites statistics",
            "POST /api/favorites/toggle": "Toggle anime in favorites",
            "GET /web": "Web interface",
        },
    }


@router.get("/health")
async def health():
    """Health check endpoint"""
    return {"status": "healthy"}


@router.get("/api/providers")
async def list_providers():
    """List all supported anime, series and file hosting providers"""
    return {
        "anime_providers": providers.get_anime_providers(),
        "series_providers": providers.get_series_providers(),
        "file_hosts": providers.get_file_hosts(),
    }
