Cleanup only, no behaviour change (ruff clean + pytest 193): - imports hoisted above `router =` and grouped/sorted (isort) across the split files; ruff-format pass restores the 2-blank-line PEP8 spacing the generator collapsed to 1. - the shared on-disk cache root moves to a neutral app/plex/cache.py, so subtitles.py no longer imports it from imgcache.py (drops the cross-import). - the former plex.py module docstring's access-model note (read endpoints open to any authed user; admin endpoints test/sync) is restored in the package __init__.py.
20 lines
488 B
Python
20 lines
488 B
Python
"""Shared helpers, serializers and constants for the plex route package."""
|
|
|
|
import logging
|
|
|
|
from fastapi import HTTPException
|
|
from sqlalchemy.orm import Session
|
|
|
|
from app.models import (
|
|
PlexItem,
|
|
)
|
|
|
|
log = logging.getLogger("siftlode.plex")
|
|
|
|
|
|
def _item_or_404(db: Session, rating_key: str) -> PlexItem:
|
|
it = db.query(PlexItem).filter_by(rating_key=str(rating_key)).first()
|
|
if it is None:
|
|
raise HTTPException(status_code=404, detail="Unknown Plex item")
|
|
return it
|