from __future__ import annotations from datetime import datetime from typing import Literal from uuid import UUID from pydantic import Field from cpv3.common.schemas import Schema from cpv3.modules.transcription.schemas import Document # --------------------------------------------------------------------------- # Caption style config sub-schemas # --------------------------------------------------------------------------- class CaptionTextStyle(Schema): font_family: str = "Lobster" font_size: int = 40 font_weight: int = 400 text_color: str = "#FFFFFF" highlight_color: str = "#FFCC00" text_shadow: str | None = "2px 2px 4px rgba(0,0,0,0.5)" text_stroke_width: float = 0 text_stroke_color: str = "#000000" class CaptionLayoutStyle(Schema): vertical_position: Literal["top", "center", "bottom"] = "bottom" horizontal_alignment: Literal["left", "center", "right"] = "center" padding_px: int = 20 max_width_pct: int = 90 lines_per_screen: int = 2 class CaptionAnimationStyle(Schema): highlight_style: Literal["color", "scale", "underline", "color_scale"] = "color" highlight_scale: float = 1.1 segment_transition: Literal["fade", "slide", "none"] = "fade" fade_duration_frames: int = 3 animation_speed: float = 1.0 class CaptionBackgroundStyle(Schema): bg_color: str = "rgba(0,0,0,0.6)" bg_blur_px: int = 0 bg_glow_color: str | None = None bg_border_radius_px: int = 15 bg_padding_px: int = 20 class CaptionStyleConfig(Schema): text: CaptionTextStyle = Field(default_factory=CaptionTextStyle) layout: CaptionLayoutStyle = Field(default_factory=CaptionLayoutStyle) animation: CaptionAnimationStyle = Field(default_factory=CaptionAnimationStyle) background: CaptionBackgroundStyle = Field(default_factory=CaptionBackgroundStyle) # --------------------------------------------------------------------------- # Preset CRUD schemas # --------------------------------------------------------------------------- class CaptionPresetCreate(Schema): name: str = Field(..., max_length=128) description: str | None = None style_config: CaptionStyleConfig class CaptionPresetUpdate(Schema): name: str | None = Field(default=None, max_length=128) description: str | None = None style_config: CaptionStyleConfig | None = None class CaptionPresetRead(Schema): id: UUID user_id: UUID | None name: str description: str | None is_system: bool style_config: CaptionStyleConfig preview_url: str | None created_at: datetime updated_at: datetime # --------------------------------------------------------------------------- # Existing request/response schemas # --------------------------------------------------------------------------- class CaptionsRequest(Schema): folder: str video_s3_path: str transcription: Document class CaptionsResponse(Schema): result: str