Initial commit: XDL Twitter/X video downloader
This commit is contained in:
21
backend/app/routes/parse.py
Normal file
21
backend/app/routes/parse.py
Normal file
@@ -0,0 +1,21 @@
|
||||
"""Video URL parsing routes."""
|
||||
from fastapi import APIRouter, HTTPException
|
||||
from app.schemas import ParseRequest, ParseResponse, FormatInfo
|
||||
from app.services.downloader import parse_video_url
|
||||
|
||||
router = APIRouter(prefix="/api", tags=["parse"])
|
||||
|
||||
|
||||
@router.post("/parse", response_model=ParseResponse)
|
||||
async def parse_url(req: ParseRequest):
|
||||
try:
|
||||
info = parse_video_url(req.url)
|
||||
return ParseResponse(
|
||||
title=info["title"],
|
||||
thumbnail=info["thumbnail"],
|
||||
duration=info["duration"],
|
||||
formats=[FormatInfo(**f) for f in info["formats"]],
|
||||
url=info["url"],
|
||||
)
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=400, detail=f"Failed to parse URL: {str(e)}")
|
||||
Reference in New Issue
Block a user