Skip to content

利用 AI 大模型和自动化工作流,根据主题或关键词一键生成高清短视频。Generate HD short videos from a topic or keyword with an automated AI workflow.

fix(skill): require --video-materials for the local video source

drakeo338f14f67880616
diff --git a/docs/skill/mpt_agent.py b/docs/skill/mpt_agent.py
index f04da35e..118eda22 100644
--- a/docs/skill/mpt_agent.py
+++ b/docs/skill/mpt_agent.py
@@ -365,6 +365,11 @@ def missing_config(config_path: Path, cli_args: list[str]) -> tuple[str, list[st
source = selected_video_source(cli_args)
if source not in SUPPORTED_SOURCES:
raise SkillError(f"unsupported video source: {source}")
+ if source == "local" and not has_cli_option(cli_args, "--video-materials"):
+ raise SkillError(
+ "Local video source requires --video-materials pointing to a "
+ "directory of video files"
+ )
if source == "volcengine_seedance":
# 与运行时 Provider 保持完全一致的凭据优先级,避免 Skill 预检通过后
# 主程序却读取了另一把 Key。ARK_API_KEY 语义过于宽泛,明确不再兼容。
diff --git a/test/services/test_mpt_agent_skill.py b/test/services/test_mpt_agent_skill.py
index a101e53d..5ed9a936 100644
--- a/test/services/test_mpt_agent_skill.py
+++ b/test/services/test_mpt_agent_skill.py
@@ -159,6 +159,33 @@ class TestMptAgentSkill(unittest.TestCase):
self.assertEqual(default_missing, ["pexels_api_keys"])
self.assertEqual(pixabay_missing, [])
+ def test_local_video_source_requires_video_materials(self):
+ """本地素材源必须提供 --video-materials,否则应提前报错。"""
+ with tempfile.TemporaryDirectory() as temp_dir:
+ config_path = Path(temp_dir) / "config.toml"
+ config_path.write_text(
+ MINIMAL_CONFIG.replace(
+ 'moonshot_api_key = ""', 'moonshot_api_key = "configured"'
+ ),
+ encoding="utf-8",
+ )
+
+ with self.assertRaisesRegex(
+ mpt_agent.SkillError, "--video-materials"
+ ):
+ mpt_agent.missing_config(config_path, ["--video-source", "local"])
+
+ _, missing = mpt_agent.missing_config(
+ config_path,
+ ["--video-source", "local", "--video-materials", "./clips"],
+ )
+ _, missing_eq = mpt_agent.missing_config(
+ config_path,
+ ["--video-source=local", "--video-materials=./clips"],
+ )
+ self.assertEqual(missing, [])
+ self.assertEqual(missing_eq, [])
+
def test_openai_image_source_accepts_keyless_local_gateway(self):
"""文生图素材源只需要端点与模型名,本地网关允许不配置 API Key。"""
with tempfile.TemporaryDirectory() as temp_dir: