8f1e03ba4c
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 24s
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / PR Build Web Image (pull_request) Has been skipped
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 1m2s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 1m20s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 1m28s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 1m44s
CI/CD Pipeline / Validate - Code Quality (pull_request) Has been cancelled
CI/CD Pipeline / Unit Tests (pull_request) Has been cancelled
CI/CD Pipeline / Integration Tests (pull_request) Has been cancelled
CI/CD Pipeline / PR Build API Image (pull_request) Has been cancelled
CI/CD Pipeline / PR Build Worker Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production API Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Web Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been cancelled
CI/CD Pipeline / Deploy Production (pull_request) Has been cancelled
CI/CD Pipeline / Production Browser E2E (pull_request) Has been cancelled
CI/CD Pipeline / Canary Release to Production (pull_request) Has been cancelled
CI/CD Pipeline / CI Gate (pull_request) Has been cancelled
AI Code Review / AI Code Review (pull_request) Has been cancelled
PR Automation / Auto Approve on CI Green (pull_request) Has been cancelled
根因:封面抽帧发生在预览视频渲染时,但用户选标题在渲染之后, 导致封面天然没有标题。 修复方案(彻底方案): 1. 调整步骤时序:前端将标题步骤移到预览之前 2. 预览 API 接收 title_config(标题文本+样式),渲染时烧录进视频 3. 封面抽帧从已带标题的视频中取帧,自然包含标题 后端改动: - generation_task.py schema: 新增 title_config dict 字段 - generation_tasks.py command: 新增 title_config 字段 - generation_preview.py: 序列化 title_config 为 JSON 存入 custom_title - generation.py worker: 解析 JSON 格式 custom_title,合并标题文本+样式到 plan.config["title"] - generation_cover.py: 移除 PR#1375 的 drawtext 临时方案(不再需要) - 删除 test_cover_title_overlay.py,新增 test_preview_title_config.py(12测试) 向后兼容: - title_config 全部可选,不传时行为和之前一致 - custom_title 支持 JSON(新)和纯文本(旧)两种格式
144 lines
4.9 KiB
Python
Executable File
144 lines
4.9 KiB
Python
Executable File
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass, field
|
|
from uuid import uuid4
|
|
|
|
from packages.domain import GenerationTask
|
|
from packages.ports.generation_task_repository import GenerationTaskRepository
|
|
|
|
|
|
@dataclass(slots=True)
|
|
class CreateGenerationTaskCommand:
|
|
project_id: str = ""
|
|
asset_library_id: str = ""
|
|
strategy_id: str = ""
|
|
voice_library_id: str = ""
|
|
template_id: str = ""
|
|
asset_ids: list[str] = field(default_factory=list)
|
|
title_ids: list[str] = field(default_factory=list)
|
|
voice_ids: list[str] = field(default_factory=list)
|
|
created_by_user_id: str = ""
|
|
source_edit_plan_id: str = ""
|
|
asset_select_mode: str = ""
|
|
batch_id: str = ""
|
|
video_title: str = ""
|
|
resolution: str = ""
|
|
bgm_config: dict = field(default_factory=dict)
|
|
auto_retry_enabled: bool = False
|
|
auto_retry_max: int = 0
|
|
is_preview: bool = False
|
|
source_task_id: str = ""
|
|
output_width: int = 1280
|
|
output_height: int = 720
|
|
cover_url: str = ""
|
|
custom_title: str = ""
|
|
title_config: dict = field(default_factory=dict)
|
|
|
|
|
|
class CreateGenerationTaskUseCase:
|
|
def __init__(self, generation_task_repository: GenerationTaskRepository):
|
|
self.generation_task_repository = generation_task_repository
|
|
|
|
def execute(self, command: CreateGenerationTaskCommand) -> GenerationTask:
|
|
task = GenerationTask(
|
|
id=uuid4().hex,
|
|
project_id=command.project_id,
|
|
asset_library_id=command.asset_library_id,
|
|
strategy_id=command.strategy_id,
|
|
voice_library_id=command.voice_library_id,
|
|
template_id=command.template_id,
|
|
asset_ids=command.asset_ids,
|
|
title_ids=command.title_ids,
|
|
voice_ids=command.voice_ids,
|
|
status="pending", # type: ignore[arg-type]
|
|
progress=0.0,
|
|
result_count=0,
|
|
error_message="",
|
|
created_by_user_id=command.created_by_user_id,
|
|
source_edit_plan_id=command.source_edit_plan_id,
|
|
asset_select_mode=command.asset_select_mode,
|
|
batch_id=command.batch_id,
|
|
video_title=command.video_title,
|
|
resolution=command.resolution,
|
|
bgm_config=command.bgm_config,
|
|
auto_retry_enabled=command.auto_retry_enabled,
|
|
auto_retry_max=command.auto_retry_max,
|
|
is_preview=command.is_preview,
|
|
source_task_id=command.source_task_id,
|
|
output_width=command.output_width,
|
|
output_height=command.output_height,
|
|
cover_url=command.cover_url,
|
|
custom_title=command.custom_title,
|
|
)
|
|
return self.generation_task_repository.create(task)
|
|
|
|
|
|
class GetGenerationTaskUseCase:
|
|
def __init__(self, generation_task_repository: GenerationTaskRepository):
|
|
self.generation_task_repository = generation_task_repository
|
|
|
|
def execute(self, task_id: str) -> GenerationTask | None:
|
|
return self.generation_task_repository.get(task_id)
|
|
|
|
|
|
@dataclass(slots=True)
|
|
class ListTasksFilter:
|
|
"""任务列表筛选条件。"""
|
|
|
|
status: str | None = None # pending, running, completed, failed, cancelled
|
|
|
|
|
|
@dataclass(slots=True)
|
|
class ListGenerationTasksResult:
|
|
"""带筛选和分页的任务列表结果。"""
|
|
|
|
items: list[GenerationTask]
|
|
total: int
|
|
|
|
|
|
class ListUserTasksFilteredUseCase:
|
|
"""按用户+筛选条件查询任务列表。"""
|
|
|
|
def __init__(self, generation_task_repository: GenerationTaskRepository):
|
|
self.generation_task_repository = generation_task_repository
|
|
|
|
def execute(
|
|
self,
|
|
user_id: str,
|
|
*,
|
|
status: str | None = None,
|
|
limit: int | None = None,
|
|
offset: int = 0,
|
|
) -> ListGenerationTasksResult:
|
|
items = self.generation_task_repository.list_by_user_filtered(
|
|
user_id,
|
|
status=status,
|
|
limit=limit,
|
|
offset=offset,
|
|
)
|
|
total = self.generation_task_repository.count_by_user_filtered(
|
|
user_id,
|
|
status=status,
|
|
)
|
|
return ListGenerationTasksResult(items=items, total=total)
|
|
|
|
|
|
class RetryGenerationTaskUseCase:
|
|
"""原地重试失败的任务(重置状态+递增retry_count)。
|
|
|
|
与创建新任务不同:复用同一个 task_id,保留历史关联。
|
|
"""
|
|
|
|
def __init__(self, generation_task_repository: GenerationTaskRepository):
|
|
self.generation_task_repository = generation_task_repository
|
|
|
|
def execute(self, task_id: str) -> GenerationTask:
|
|
task = self.generation_task_repository.get(task_id)
|
|
if task is None:
|
|
raise ValueError(f"任务不存在: {task_id}")
|
|
if not task.is_failed:
|
|
raise ValueError(f"只有失败状态的任务才能重试,当前状态: {task.status.value}")
|
|
task.mark_pending_from_failed()
|
|
self.generation_task_repository.update(task)
|
|
return task
|