add merging sentences action

This commit is contained in:
2026-09-04 09:09:34 +08:00
parent a38679d4a0
commit ff1341e191
6 changed files with 287 additions and 4 deletions

View File

@@ -565,6 +565,27 @@ def create_app(
raise HTTPException(status_code=404, detail="Sentence was not found.")
return result
@application.put(
"/api/v1/admin/videos/{video_hash}/sentences/{sentence_index}/merge",
response_model=SentenceBoundary,
dependencies=[Depends(require_admin)],
)
def merge_sentence(
video_hash: str = SHA256_PATH,
sentence_index: int = ApiPath(ge=0),
) -> SentenceBoundary:
try:
sentence = video_repository.merge_with_next_sentence(
video_hash,
sentence_index,
)
except ValueError as exc:
raise HTTPException(status_code=400, detail=str(exc)) from exc
if sentence is None:
raise HTTPException(status_code=404, detail="Sentence was not found.")
return sentence
@application.put(
"/api/v1/admin/videos/{video_hash}/sentences/{sentence_index}/boundary",
response_model=List[SentenceBoundary],