import uuid
from datetime import datetime
from typing import List, Optional
from pydantic import BaseModel, Field 


class VideoBase(BaseModel):
    title: str = Field(..., description="Title of the video")
    duration: int = Field(..., description="Duration of the video in seconds")
    source: str = Field(..., description="Source of the video (file_path or URL)")
    results: dict = Field(..., description="Results of object detection")


class VideoCreate(VideoBase):
    pass


class VideoUpdate(VideoBase):
    pass


class VideoBaseSchema(VideoBase):
    id: str = Field(default_factory=str(uuid.uuid4()), description="UUID of the video")
    published: bool = Field(..., description="Publish status of the video")
    createdAt: datetime = Field(default_factory=datetime.now, description="Creation timestamp")
    updatedAt: Optional[datetime] = Field(default=None, description="Update timestamp")

    class Config:
        orm_mode = True


class VideoList(BaseModel):
    videos: List[VideoBaseSchema]


class VideoListResponse(BaseModel):
    data: VideoList
