PlexLibrary, PlexShow, PlexSeason, PlexItem, PlexPerson, PlexCollection, PlexState, PlexLink, PlexPlaylist and PlexPlaylistItem leave app/models.py for app/plex/models.py; app.tables registers them. Every import is re-pointed; no schema change.
19 lines
565 B
Python
19 lines
565 B
Python
"""Shared helpers, serializers and constants for the plex route package."""
|
|
|
|
from sqlalchemy.orm import Session
|
|
|
|
from app import logs
|
|
from app.plex.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
|