- новый api/: /pipeline/process (yt-dlp, субтитры или Vosk, LLM/экстрактивная суммаризация), /videos, /llm; старый код перенесён в api_legacy/ - web/: Flet UI (flet 0.28.3 + flet-web, порт 8550) - Dockerfile.api: ffmpeg слоем из mwader/static-ffmpeg, pip с кэш-маунтом - requirements/pyproject: убраны moviepy, imageio-ffmpeg, битый asyncio - README с инструкцией запуска и загрузкой Vosk-модели Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
56 lines
1.3 KiB
Python
56 lines
1.3 KiB
Python
from datetime import datetime
|
|
from typing import List
|
|
|
|
from fastapi import APIRouter, HTTPException
|
|
from pydantic import BaseModel
|
|
|
|
from api.db.video import delete_video, get_video, list_videos
|
|
|
|
|
|
router = APIRouter(prefix="/videos", tags=["videos"])
|
|
|
|
|
|
class VideoOut(BaseModel):
|
|
uuid: str
|
|
source_url: str
|
|
title: str
|
|
video_path: str
|
|
text_full_path: str
|
|
text_summary_path: str
|
|
transcription_method: str
|
|
created_at: datetime
|
|
|
|
|
|
def _to_out(v) -> VideoOut:
|
|
return VideoOut(
|
|
uuid=v.uuid,
|
|
source_url=v.source_url,
|
|
title=v.title,
|
|
video_path=v.video_path,
|
|
text_full_path=v.text_full_path,
|
|
text_summary_path=v.text_summary_path,
|
|
transcription_method=v.transcription_method,
|
|
created_at=v.created_at,
|
|
)
|
|
|
|
|
|
@router.get("/", response_model=List[VideoOut])
|
|
async def list_all():
|
|
return [_to_out(v) for v in await list_videos()]
|
|
|
|
|
|
@router.get("/{video_uuid}", response_model=VideoOut)
|
|
async def get_one(video_uuid: str):
|
|
v = await get_video(video_uuid)
|
|
if not v:
|
|
raise HTTPException(status_code=404, detail="Video not found")
|
|
return _to_out(v)
|
|
|
|
|
|
@router.delete("/{video_uuid}")
|
|
async def delete_one(video_uuid: str):
|
|
ok = await delete_video(video_uuid)
|
|
if not ok:
|
|
raise HTTPException(status_code=404, detail="Video not found")
|
|
return {"ok": True}
|