Spaces:
Running
Running
Download app/schemas/library.py from MonteeqOrg/backend: direct link, hf CLI and curl.
- Browser
- Download file 3.11 kB
-
https://huggingface.co/spaces/MonteeqOrg/backend/resolve/main/app/schemas/library.py
- Command line
-
hf download hf://spaces/MonteeqOrg/backend/app/schemas/library.py
-
curl -L -o library.py https://huggingface.co/spaces/MonteeqOrg/backend/resolve/main/app/schemas/library.py
3.11 kB
| from pydantic import BaseModel, ConfigDict, field_serializer | |
| from typing import List, Optional, Union | |
| from datetime import datetime | |
| from uuid import UUID | |
| # ββ Base Video Schema for Library βββββββββββββββββββββββββββββββββββββββββββ | |
| class LibraryVideo(BaseModel): | |
| id: Union[int, str] # Using Union to allow serialization to string | |
| public_id: Optional[str] = None | |
| title: str | |
| thumbnail_url: str | |
| duration: int # Mapping duration_seconds to duration | |
| views: int | |
| owner_id: int | |
| created_at: datetime | |
| tags: Optional[str] = None | |
| creator_name: Optional[str] = None | |
| def serialize_id(self, v: int) -> Union[int, str]: | |
| return self.public_id if (hasattr(self, 'public_id') and self.public_id) else v | |
| model_config = ConfigDict(from_attributes=True) | |
| # ββ History ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| class HistoryItem(BaseModel): | |
| id: UUID | |
| video: LibraryVideo | |
| watched_at: datetime | |
| progress_seconds: int | |
| duration_seconds: int | |
| is_completed: bool | |
| model_config = ConfigDict(from_attributes=True) | |
| class HistoryResponse(BaseModel): | |
| items: List[HistoryItem] | |
| page: int | |
| limit: int | |
| total: int | |
| has_more: bool | |
| class HistoryProgressUpdate(BaseModel): | |
| progress_seconds: int | |
| duration_seconds: int | |
| is_completed: bool | |
| class HistoryTrackRequest(BaseModel): | |
| video_id: Union[int, str] | |
| progress_seconds: float | |
| duration_seconds: float | |
| is_completed: bool | |
| # ββ Watch Later βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| class WatchLaterItem(BaseModel): | |
| id: UUID | |
| video: LibraryVideo | |
| saved_at: datetime | |
| model_config = ConfigDict(from_attributes=True) | |
| class WatchLaterStats(BaseModel): | |
| total_videos: int | |
| total_runtime_seconds: int | |
| new_this_week: int | |
| class WatchLaterResponse(BaseModel): | |
| items: List[WatchLaterItem] | |
| stats: WatchLaterStats | |
| # ββ Liked Videos βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| class LikedItem(BaseModel): | |
| id: UUID | |
| video: LibraryVideo | |
| liked_at: datetime | |
| model_config = ConfigDict(from_attributes=True) | |
| class LikedResponse(BaseModel): | |
| items: List[LikedItem] | |
| page: int | |
| limit: int | |
| total: int | |
| has_more: bool | |
| # ββ Shared βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| class LibraryStats(BaseModel): | |
| history_count: int | |
| watch_later_count: int | |
| liked_count: int | |