feat: inspect public video sources with yt-dlp

This commit is contained in:
bot
2026-08-11 15:19:35 +03:00
parent f7e668d692
commit db75f2c4f8
7 changed files with 486 additions and 1 deletions
+16
View File
@@ -1,4 +1,9 @@
from fastapi import FastAPI
from fastapi import HTTPException
from starlette.concurrency import run_in_threadpool
from app.inspection import InspectionError, UnsafeUrlError, inspect_url
from app.models import InspectionRequest, InspectionResponse
app = FastAPI(
title="Media Ingest",
@@ -16,3 +21,14 @@ def root() -> dict[str, str]:
def health() -> dict[str, str]:
"""Report whether the application process can serve requests."""
return {"status": "healthy"}
@app.post("/api/inspect", response_model=InspectionResponse, tags=["inspection"])
async def inspect_source(request: InspectionRequest) -> dict[str, object]:
"""Inspect a public video URL without downloading media."""
try:
return await run_in_threadpool(inspect_url, request.url)
except UnsafeUrlError as error:
raise HTTPException(status_code=400, detail=str(error)) from error
except InspectionError as error:
raise HTTPException(status_code=422, detail=str(error)) from error