Initial commit: XDL Twitter/X video downloader

This commit is contained in:
mini
2026-02-18 17:15:12 +08:00
commit 7fdd181728
32 changed files with 1230 additions and 0 deletions

85
backend/app/schemas.py Normal file
View File

@@ -0,0 +1,85 @@
"""Pydantic schemas for request/response validation."""
from pydantic import BaseModel
from typing import Optional
from datetime import datetime
class ParseRequest(BaseModel):
url: str
class FormatInfo(BaseModel):
format_id: str
quality: str
ext: str
filesize: Optional[int] = None
note: str = ""
class ParseResponse(BaseModel):
title: str
thumbnail: str
duration: int
formats: list[FormatInfo]
url: str
class DownloadRequest(BaseModel):
url: str
format_id: str = "best"
quality: str = ""
class DownloadResponse(BaseModel):
task_id: str
status: str
class TaskStatus(BaseModel):
task_id: str
status: str
progress: int
title: str = ""
error_message: str = ""
video_id: Optional[int] = None
class VideoInfo(BaseModel):
id: int
task_id: str
url: str
title: str
platform: str
thumbnail: str
quality: str
filename: str
file_size: int
duration: int
status: str
created_at: datetime
class Config:
from_attributes = True
class VideoListResponse(BaseModel):
videos: list[VideoInfo]
total: int
page: int
page_size: int
class StorageStats(BaseModel):
total_videos: int
total_size: int
total_size_human: str
class LoginRequest(BaseModel):
username: str
password: str
class TokenResponse(BaseModel):
access_token: str
token_type: str = "bearer"