mirror of
https://github.com/MrSleeps/jellyfin-scene-search.git
synced 2026-11-14 22:11:27 +00:00
Add safe draft and published Overview editor
This commit is contained in:
+21
-1
@@ -15,7 +15,7 @@ from .database import connect, init_db
|
|||||||
from .frame_source import FrameSource
|
from .frame_source import FrameSource
|
||||||
from .index_jobs import IndexJobManager
|
from .index_jobs import IndexJobManager
|
||||||
from .overview_jobs import OverviewJobManager
|
from .overview_jobs import OverviewJobManager
|
||||||
from .overviews import overview_inventory
|
from .overviews import overview_inventory, edit_overview
|
||||||
from .search_service import SearchService
|
from .search_service import SearchService
|
||||||
|
|
||||||
WEB_INDEX_PATH = Path(__file__).parent / "web" / "index.html"
|
WEB_INDEX_PATH = Path(__file__).parent / "web" / "index.html"
|
||||||
@@ -51,6 +51,11 @@ class CaptionRequest(BaseModel):
|
|||||||
folder_path: str | None = None
|
folder_path: str | None = None
|
||||||
|
|
||||||
|
|
||||||
|
class OverviewEditRequest(BaseModel):
|
||||||
|
expected_overview: str
|
||||||
|
overview: str = Field(min_length=1, max_length=12000)
|
||||||
|
|
||||||
|
|
||||||
class OverviewRequest(BaseModel):
|
class OverviewRequest(BaseModel):
|
||||||
action: str
|
action: str
|
||||||
media_id: str | None = None
|
media_id: str | None = None
|
||||||
@@ -391,6 +396,21 @@ def overview_items(
|
|||||||
raise HTTPException(status_code=400, detail=str(exc)) from exc
|
raise HTTPException(status_code=400, detail=str(exc)) from exc
|
||||||
|
|
||||||
|
|
||||||
|
@app.patch("/api/overviews/{media_id}", dependencies=[Depends(require_api_key)])
|
||||||
|
def overview_edit(media_id: str, request: OverviewEditRequest) -> dict:
|
||||||
|
if get_overview_jobs().running or get_index_jobs().running:
|
||||||
|
raise HTTPException(status_code=409, detail="Wait until Overview/indexing jobs finish")
|
||||||
|
try:
|
||||||
|
return edit_overview(
|
||||||
|
db_path=settings.db_path, media_id=media_id,
|
||||||
|
expected_overview=request.expected_overview, overview=request.overview,
|
||||||
|
)
|
||||||
|
except ValueError as exc:
|
||||||
|
raise HTTPException(status_code=400, detail=str(exc)) from exc
|
||||||
|
except RuntimeError as exc:
|
||||||
|
raise HTTPException(status_code=409, detail=str(exc)) from exc
|
||||||
|
|
||||||
|
|
||||||
@app.get("/api/overviews/status", dependencies=[Depends(require_api_key)])
|
@app.get("/api/overviews/status", dependencies=[Depends(require_api_key)])
|
||||||
def overview_status() -> dict:
|
def overview_status() -> dict:
|
||||||
return get_overview_jobs().status()
|
return get_overview_jobs().status()
|
||||||
|
|||||||
Reference in New Issue
Block a user