fix(platform): AutoDL 插件 - 修复视频分辨率后缀丢失并升级插件包

This commit is contained in:
ddCat
2026-08-28 14:13:03 +08:00
parent 335b5406ad
commit bf093dba92
7 changed files with 39 additions and 7 deletions

View File

@@ -25,7 +25,7 @@ func TestAutoDLPluginArtifact(t *testing.T) {
t.Fatalf("loaded adapters = %d", len(adapters))
}
adapter := adapters[0]
if adapter.Metadata().ID != "autodl-comfyui" || adapter.Metadata().Execution != "declarative" {
if adapter.Metadata().ID != "autodl-comfyui" || adapter.Metadata().Version != "1.0.1" || adapter.Metadata().Execution != "declarative" {
t.Fatalf("metadata = %#v", adapter.Metadata())
}
if !adapter.Metadata().RequiresPublicMediaURLs {
@@ -33,7 +33,7 @@ func TestAutoDLPluginArtifact(t *testing.T) {
}
create, err := adapter.BuildCreate(context.Background(), RequestContext{BaseURL: "https://autodl.art", Request: GenerationRequest{
Model: "minimax_h3_lightx2v_no_pic", Prompt: "a cinematic test", Duration: 3, Resolution: "768P", Images: []MediaReference{{URL: "https://cdn.example/reference.png"}},
Model: "minimax_h3_lightx2v_no_pic", Prompt: "a cinematic test", Duration: 3, Resolution: "768", Images: []MediaReference{{URL: "https://cdn.example/reference.png"}},
}})
if err != nil {
t.Fatal(err)

View File

@@ -365,6 +365,23 @@ func TestDeclarativeManifestSupportsMediaPathsTransformsAndErrors(t *testing.T)
}
}
func TestDeclarativeManifestNormalizesVideoResolutionWithoutBreakingWorkflowValues(t *testing.T) {
tests := map[string]string{
"768": "768p",
"768p": "768p",
"768P": "768p",
" 768P ": "768p",
"768p竖": "768p竖",
"768P横": "768p横",
"2K": "2k",
}
for input, expected := range tests {
if actual := applyManifestTransform(input, "video-resolution"); actual != expected {
t.Errorf("video resolution transform %q = %#v, want %q", input, actual, expected)
}
}
}
func TestDeclarativeManifestRequiresDocumentation(t *testing.T) {
manifest := Manifest{
APIVersion: "v1",

View File

@@ -10,7 +10,7 @@ AutoDL 的模型选择对应 ComfyUI 工作流 ID。不同工作流可以声明
## 参数
请求体为 JSON。常用字段包括 `prompt`、`duration` 和 `resolution`;实际工作流可以扩展自己的参数 schema。状态返回值位于 `data.status`,任务 ID 位于 `data.task_id`,成功结果位于 `data.results`。结果数组中的地址是短期 URL,成功后必须立即由宿主下载到影策资源存储,不能把临时地址直接写入画布长期数据。
请求体为 JSON。常用字段包括 `prompt`、`duration` 和 `resolution`;实际工作流可以扩展自己的参数 schema。插件使用 `video-resolution` 字段变换:历史状态中的纯数字 `768` 会发送为 `768p`,已经带后缀的 `768p` 以及工作流值 `768p竖`、`768p横` 保持其语义。状态返回值位于 `data.status`,任务 ID 位于 `data.task_id`,成功结果位于 `data.results`。结果数组中的地址是短期 URL,成功后必须立即由宿主下载到影策资源存储,不能把临时地址直接写入画布长期数据。
## 鉴权

View File

@@ -554,11 +554,26 @@ func applyManifestTransform(value any, transform string) any {
return strings.ToLower(text)
case "upper", "uppercase":
return strings.ToUpper(text)
case "video-resolution", "video_resolution", "videoresolution":
return normalizeManifestVideoResolution(text)
default:
return value
}
}
func normalizeManifestVideoResolution(value string) string {
normalized := strings.ToLower(strings.TrimSpace(value))
if normalized == "" {
return ""
}
for _, char := range normalized {
if char < '0' || char > '9' {
return normalized
}
}
return normalized + "p"
}
func pathValue(payload map[string]any, path string) any {
var value any = payload
for _, part := range strings.Split(strings.Trim(path, "."), ".") {