# Copyright (C) 2025 AIDC-AI # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # http://www.apache.org/licenses/LICENSE-2.0 # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """ Publish API schemas """ from pydantic import BaseModel, Field from typing import List, Optional, Dict, Any from enum import Enum class PlatformEnum(str, Enum): export = "export" bilibili = "bilibili" youtube = "youtube" class PublishStatusEnum(str, Enum): pending = "pending" converting = "converting" uploading = "uploading" processing = "processing" published = "published" failed = "failed" class VideoMetadataSchema(BaseModel): """Video metadata for publishing""" title: str = Field(..., min_length=1, max_length=100) description: str = Field("", max_length=5000) tags: List[str] = Field(default_factory=list) category: Optional[str] = None cover_path: Optional[str] = None privacy: str = Field("public", pattern="^(public|private|unlisted)$") platform_options: Dict[str, Any] = Field(default_factory=dict) class PublishRequest(BaseModel): """Request to publish a video""" video_path: str = Field(..., description="Path to the video file") metadata: VideoMetadataSchema class PublishResultSchema(BaseModel): """Result of a publishing operation""" success: bool platform: str status: PublishStatusEnum video_url: Optional[str] = None platform_video_id: Optional[str] = None error_message: Optional[str] = None export_path: Optional[str] = None class PublishTaskSchema(BaseModel): """A publishing task""" id: str platform: str status: PublishStatusEnum result: Optional[PublishResultSchema] = None created_at: str updated_at: Optional[str] = None class PlatformRequirementsSchema(BaseModel): """Platform requirements""" max_file_size_mb: int max_duration_seconds: Optional[int] = None supported_formats: List[str] = [] recommended_resolution: tuple = (1080, 1920) recommended_codec: str = "h264"