mirror of
https://github.com/MrSleeps/jellyfin-scene-search.git
synced 2026-11-17 23:41:28 +00:00
Allow caption jobs to target an indexed Jellyfin folder
This commit is contained in:
@@ -37,6 +37,7 @@ class IndexRequest(BaseModel):
|
|||||||
class CaptionRequest(BaseModel):
|
class CaptionRequest(BaseModel):
|
||||||
library_ids: list[str] = Field(min_length=1)
|
library_ids: list[str] = Field(min_length=1)
|
||||||
force: bool = False
|
force: bool = False
|
||||||
|
folder_path: str | None = None
|
||||||
|
|
||||||
|
|
||||||
def get_search_service() -> SearchService:
|
def get_search_service() -> SearchService:
|
||||||
@@ -172,6 +173,7 @@ def jellyfin_index(request: IndexRequest) -> dict:
|
|||||||
return get_index_jobs().start(
|
return get_index_jobs().start(
|
||||||
request.library_ids,
|
request.library_ids,
|
||||||
force=request.force,
|
force=request.force,
|
||||||
|
folder_path=request.folder_path,
|
||||||
)
|
)
|
||||||
except RuntimeError as exc:
|
except RuntimeError as exc:
|
||||||
message = str(exc)
|
message = str(exc)
|
||||||
@@ -210,6 +212,26 @@ def jellyfin_index_report(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/api/caption/folders", dependencies=[Depends(require_api_key)])
|
||||||
|
def caption_folders(library_id: str = Query(min_length=1)) -> dict:
|
||||||
|
"""List indexed folder paths within a library, for optional caption batching."""
|
||||||
|
from pathlib import PurePosixPath
|
||||||
|
with connect(settings.db_path) as con:
|
||||||
|
paths = con.execute(
|
||||||
|
"""SELECT DISTINCT source_path FROM media
|
||||||
|
WHERE source_kind = 'jellyfin' AND jellyfin_library_id = ?
|
||||||
|
AND source_path IS NOT NULL AND source_path != ''""",
|
||||||
|
(library_id,),
|
||||||
|
).fetchall()
|
||||||
|
folders: set[str] = set()
|
||||||
|
for item in paths:
|
||||||
|
path = str(item["source_path"]).replace("\\", "/")
|
||||||
|
parent = str(PurePosixPath(path).parent)
|
||||||
|
if parent not in ("", ".", "/"):
|
||||||
|
folders.add(parent)
|
||||||
|
return {"folders": sorted(folders, key=str.casefold)}
|
||||||
|
|
||||||
|
|
||||||
@app.post(
|
@app.post(
|
||||||
"/api/caption",
|
"/api/caption",
|
||||||
dependencies=[Depends(require_api_key)],
|
dependencies=[Depends(require_api_key)],
|
||||||
|
|||||||
Reference in New Issue
Block a user