add merging sentences action
This commit is contained in:
@@ -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],
|
||||
|
||||
Reference in New Issue
Block a user