"""Shared helpers, serializers and constants for the plex route package.""" from fastapi import HTTPException from sqlalchemy.orm import Session from app import logs from app.models import PlexItem from app.plex.lookups import by_rating_key log = logs.get_logger(__name__) def item_or_404(db: Session, rating_key: str) -> PlexItem: it = by_rating_key(db, PlexItem, rating_key) if it is None: raise HTTPException(status_code=404, detail="Unknown Plex item") return it def _norm_lang(lang: str | None) -> str: """The overlay has an EN base + an optional HU twin; anything other than `hu` serves EN.""" return "hu" if lang == "hu" else "en"