allow ajust sentences

This commit is contained in:
2026-08-30 11:07:50 +08:00
parent 508a26ba02
commit 0d0b82e095
9 changed files with 270 additions and 3 deletions

View File

@@ -32,6 +32,7 @@ from .audio_metrics import AudioAnalysisError
from .config import Settings
from .models import (
AssessmentResult,
SentenceBoundaryAdjust,
SentenceBoundary,
SentenceBoundaryDocument,
SentenceTextUpdate,
@@ -363,6 +364,28 @@ 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}/boundary",
response_model=List[SentenceBoundary],
dependencies=[Depends(require_admin)],
)
def adjust_sentence_boundary(
payload: SentenceBoundaryAdjust,
video_hash: str = SHA256_PATH,
sentence_index: int = ApiPath(ge=0),
) -> List[SentenceBoundary]:
try:
result = video_repository.adjust_sentence_boundary(
video_hash,
sentence_index,
payload.delta_ms,
)
except ValueError as exc:
raise HTTPException(status_code=400, detail=str(exc)) from exc
if result is None:
raise HTTPException(status_code=404, detail="Sentence or video was not found.")
return result
@application.delete(
"/api/v1/admin/videos/{video_hash}",
status_code=204,