diff --git a/src/BowongModalFunctions/models/media_model.py b/src/BowongModalFunctions/models/media_model.py index 335bf02..d00a132 100644 --- a/src/BowongModalFunctions/models/media_model.py +++ b/src/BowongModalFunctions/models/media_model.py @@ -1,4 +1,5 @@ import os +import re from datetime import datetime from enum import Enum from functools import cached_property @@ -53,8 +54,15 @@ class MediaSource(BaseModel): endpoint=parsed_url.netloc, # domain of http url bucket=None, urn=media_url) - elif media_url.startswith('s3://'): # s3://{endpoint}/{bucket}/{url} + elif media_url.startswith('s3://'): + + pattern = r"^s3://[a-z]{2}-[a-z]+-\d/.*$" + if not re.match(pattern, media_url): + media_url = media_url.replace("s3://", f"s3://{s3_region}/") + # s3://{endpoint}/{bucket}/{url} paths = media_url[5:].split('/') + + if len(paths) < 3: raise ValidationError("URN-s3 格式错误") diff --git a/src/BowongModalFunctions/models/web_model.py b/src/BowongModalFunctions/models/web_model.py index f18c3c8..658062f 100644 --- a/src/BowongModalFunctions/models/web_model.py +++ b/src/BowongModalFunctions/models/web_model.py @@ -319,7 +319,7 @@ class ComfyTaskStatusResponse(BaseModel): class ComfyTaskRequest(BaseFFMPEGTaskRequest): video_path: MediaSource = Field( - default=MediaSource.from_str("s3://modal-media-cache/comfyui-input/markers/1016.mp4"), description="视频源") + default=None, description="视频源") start_time: str = Field(default="00:00:01.600", description="开始时间") filename_prefix: str = Field(default=str(uuid.uuid4()), description="生成文件名前缀") tts_text1: str = Field(default="好好看,这是我们家专门为女生定制的背心,", description="tts文本1")