"""Shared helpers, serializers and constants for the plex route package.""" from sqlalchemy.orm import Session from app import logs from app.models import PlexItem from app.plex.lookups import by_rating_key from app.routes._common import not_found 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 not_found("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"