mirror of
https://github.com/xpltdco/media-rip.git
synced 2026-04-03 10:54:00 -06:00
Full-featured self-hosted yt-dlp web frontend:
- Python 3.12+ / FastAPI backend with async SQLite, SSE transport, session isolation
- Vue 3 / TypeScript / Pinia frontend with real-time progress, theme picker
- 3 built-in themes (cyberpunk/dark/light) + drop-in custom theme system
- Admin auth (bcrypt), purge system, cookie upload, file serving
- Docker multi-stage build, GitHub Actions CI/CD
- 179 backend tests, 29 frontend tests (208 total)
Slices: S01 (Foundation), S02 (SSE+Sessions), S03 (Frontend),
S04 (Admin+Auth), S05 (Themes), S06 (Docker+CI)
36 lines
1 KiB
Python
36 lines
1 KiB
Python
"""Format extraction API route.
|
|
|
|
GET /formats?url= — return available download formats for a URL
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import logging
|
|
|
|
from fastapi import APIRouter, Query, Request
|
|
from fastapi.responses import JSONResponse
|
|
|
|
from app.models.job import FormatInfo
|
|
|
|
logger = logging.getLogger("mediarip.api.formats")
|
|
|
|
router = APIRouter(tags=["formats"])
|
|
|
|
|
|
@router.get("/formats", response_model=list[FormatInfo])
|
|
async def get_formats(
|
|
request: Request,
|
|
url: str = Query(..., description="URL to extract formats from"),
|
|
) -> list[FormatInfo] | JSONResponse:
|
|
"""Extract available formats for a URL via yt-dlp."""
|
|
logger.debug("GET /formats url=%s", url)
|
|
download_service = request.app.state.download_service
|
|
try:
|
|
formats = await download_service.get_formats(url)
|
|
return formats
|
|
except Exception as exc:
|
|
logger.error("Format extraction failed for %s: %s", url, exc)
|
|
return JSONResponse(
|
|
status_code=400,
|
|
content={"detail": f"Format extraction failed: {exc}"},
|
|
)
|