"""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.cards import norm_lang as _norm_lang # noqa: F401 — the package's historic name 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