allow ajust sentences
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user