from typing import AnyStr

from fastapi import APIRouter, Request
from fastapi.templating import Jinja2Templates
from src.db.models.media import MediaActor
from src.db.session import SessionDep

templates = Jinja2Templates(directory="src/templates")
router = APIRouter(include_in_schema=False, prefix="/media")


@router.get("/actors")
def get_actors(db: SessionDep, request: Request, msg: str | None = None):
    actors = db.query(MediaActor).all()
    return templates.TemplateResponse("media/actors.html", {"request": request, "msg": msg, "actors": actors})

@router.get("/actors/{actor_id}")
def artist_detail(actor_id: AnyStr, request: Request, db: SessionDep):
    actor = db.get(MediaActor, actor_id)
    return templates.TemplateResponse("media/actor_detail.html", {"request": request, "actor": actor})

