init: new structure + fix lint errors

This commit is contained in:
Daniil
2026-02-03 02:15:07 +03:00
commit 67e0f22b4f
89 changed files with 7654 additions and 0 deletions
View File
+23
View File
@@ -0,0 +1,23 @@
from __future__ import annotations
from fastapi import APIRouter, Depends
from cpv3.infrastructure.auth import get_current_user
from cpv3.modules.captions.schemas import CaptionsRequest, CaptionsResponse
from cpv3.modules.captions.service import generate_captions
from cpv3.modules.users.models import User
router = APIRouter(prefix="/api/captions", tags=["Captions"])
@router.post("/get_video/", response_model=CaptionsResponse)
async def get_video(
body: CaptionsRequest, current_user: User = Depends(get_current_user)
) -> CaptionsResponse:
_ = current_user
result = await generate_captions(
folder=body.folder,
video_s3_path=body.video_s3_path,
transcription=body.transcription,
)
return CaptionsResponse(result=result)
+14
View File
@@ -0,0 +1,14 @@
from __future__ import annotations
from cpv3.common.schemas import Schema
from cpv3.modules.transcription.schemas import Document
class CaptionsRequest(Schema):
folder: str
video_s3_path: str
transcription: Document
class CaptionsResponse(Schema):
result: str
+31
View File
@@ -0,0 +1,31 @@
from __future__ import annotations
import httpx
from cpv3.infrastructure.settings import get_settings
from cpv3.modules.transcription.schemas import Document
async def generate_captions(
*, video_s3_path: str, folder: str, transcription: Document
) -> str:
"""Generate captions for a video using the Remotion service."""
settings = get_settings()
payload = {
"folder": folder,
"videoSrc": video_s3_path,
"transcription": transcription.model_dump(),
}
async with httpx.AsyncClient(timeout=300) as client:
resp = await client.post(
f"{settings.remotion_service_url}/api/render", json=payload
)
resp.raise_for_status()
data = resp.json()
if not isinstance(data, dict) or "output" not in data:
raise RuntimeError("Unexpected response from remotion service")
return str(data["output"])