update
This commit is contained in:
47
backend/api/schemas.py
Normal file
47
backend/api/schemas.py
Normal file
@@ -0,0 +1,47 @@
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class VideoCreate(BaseModel):
|
||||
title: str
|
||||
youtuber: str
|
||||
thumbnail_url: str
|
||||
youtube_url: str
|
||||
profile_id: int | None = None
|
||||
|
||||
|
||||
class VideoResponse(BaseModel):
|
||||
id: int
|
||||
title: str
|
||||
youtuber: str
|
||||
thumbnail_url: str
|
||||
youtube_url: str
|
||||
is_downloaded: bool
|
||||
profile_ids: list[int]
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
@classmethod
|
||||
def from_model(cls, video):
|
||||
return cls(
|
||||
id=video.id,
|
||||
title=video.title,
|
||||
youtuber=video.youtuber,
|
||||
thumbnail_url=video.thumbnail_url,
|
||||
youtube_url=video.youtube_url,
|
||||
is_downloaded=video.file_path is not None,
|
||||
profile_ids=[p.id for p in video.profiles],
|
||||
)
|
||||
|
||||
|
||||
class CleanupRequest(BaseModel):
|
||||
profile_id: int
|
||||
exclude_ids: list[int] = []
|
||||
|
||||
|
||||
class ProfileResponse(BaseModel):
|
||||
id: int
|
||||
name: str
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
Reference in New Issue
Block a user