132 lines
2.2 KiB
Python
132 lines
2.2 KiB
Python
"""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
|
|
platform: 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"
|
|
|
|
|
|
class DownloadLogInfo(BaseModel):
|
|
id: int
|
|
video_id: int
|
|
video_title: str = ""
|
|
video_platform: str = ""
|
|
ip: str
|
|
user_agent: str
|
|
browser: str
|
|
device: str
|
|
country_code: str = ""
|
|
country: str = ""
|
|
city: str = ""
|
|
downloaded_at: datetime
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class DownloadLogListResponse(BaseModel):
|
|
logs: list[DownloadLogInfo]
|
|
total: int
|
|
page: int
|
|
page_size: int
|
|
|
|
|
|
class CleanupConfig(BaseModel):
|
|
enabled: bool = True
|
|
retention_minutes: int = 10080 # 7 days
|
|
storage_limit_pct: int = 80
|
|
|
|
|
|
class DiskStats(BaseModel):
|
|
total: int
|
|
used: int
|
|
free: int
|
|
used_pct: float
|
|
|
|
|
|
class CleanupStatus(BaseModel):
|
|
config: CleanupConfig
|
|
disk: DiskStats
|
|
last_run: str = ""
|
|
last_result: dict = {}
|