Skip to content

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

fix(cli): allow the WaveSpeed video source from the command line

c020627abdd0442a00a
diff --git a/cli.py b/cli.py
index 3f21647e..16208666 100644
--- a/cli.py
+++ b/cli.py
@@ -41,6 +41,7 @@ _CLI_VIDEO_SOURCES = (
"pexels",
"pixabay",
"coverr",
+ "wavespeed",
"volcengine_seedance",
"ofox",
"metaso_minimax",
@@ -360,6 +361,14 @@ Batch manifests:
choices=_PIPELINE_STAGES,
help="stop after this pipeline stage; see the stage order below",
)
+ material_group.add_argument(
+ "--confirm-wavespeed-charge",
+ action="store_true",
+ help=(
+ "confirm that WaveSpeed video generation creates paid tasks; required "
+ "with --video-source wavespeed for materials or video output"
+ ),
+ )
material_group.add_argument(
"--confirm-seedance-charge",
action="store_true",
@@ -708,6 +717,16 @@ Batch manifests:
)
if not args.batch_file and args.video_source != "local" and has_video_materials:
parser.error("--video-materials can only be used with --video-source local")
+ if (
+ not args.batch_file
+ and args.video_source == "wavespeed"
+ and stage_requires_materials
+ and not args.confirm_wavespeed_charge
+ ):
+ parser.error(
+ "--confirm-wavespeed-charge is required with "
+ "--video-source wavespeed"
+ )
if (
not args.batch_file
and args.video_source == "volcengine_seedance"
@@ -1134,6 +1153,7 @@ def _validate_batch_task_params(
*,
stop_at: str,
custom_position_is_explicit: bool,
+ wavespeed_charge_confirmed: bool,
seedance_charge_confirmed: bool,
ofox_charge_confirmed: bool,
metaso_minimax_charge_confirmed: bool,
@@ -1169,6 +1189,14 @@ def _validate_batch_task_params(
)
if params.video_source != "local" and params.video_materials:
raise ValueError("video_materials can only be used with video_source=local")
+ if (
+ params.video_source == "wavespeed"
+ and stop_at in {"materials", "video"}
+ and not wavespeed_charge_confirmed
+ ):
+ raise ValueError(
+ "--confirm-wavespeed-charge is required for WaveSpeed video generation"
+ )
if (
params.video_source == "volcengine_seedance"
and stop_at in {"materials", "video"}
@@ -1299,6 +1327,7 @@ def _build_batch_tasks(args: argparse.Namespace) -> list[VideoParams]:
or "custom_position" in override_fields
),
seedance_charge_confirmed=args.confirm_seedance_charge,
+ wavespeed_charge_confirmed=args.confirm_wavespeed_charge,
ofox_charge_confirmed=args.confirm_ofox_charge,
metaso_minimax_charge_confirmed=(
args.confirm_metaso_minimax_charge
diff --git a/test/services/test_cli.py b/test/services/test_cli.py
index c4598b8b..90293e27 100644
--- a/test/services/test_cli.py
+++ b/test/services/test_cli.py
@@ -232,6 +232,74 @@ class TestCli(unittest.TestCase):
cli.build_video_params(args).video_source, "volcengine_seedance"
)
+ def test_wavespeed_video_source_requires_explicit_charge_confirmation(self):
+ # WaveSpeed is the WebUI's original per-request billed generator, gated
+ # on the same "Confirm WaveSpeed Charge" checkbox the siblings use.
+ # Rejecting the source outright kept the CLI from reaching a generator
+ # that config.example.toml advertises.
+ with self.assertRaises(SystemExit) as raised:
+ cli.parse_args(["--video-subject", "test", "--video-source", "wavespeed"])
+ self.assertEqual(raised.exception.code, 2)
+
+ args = cli.parse_args(
+ [
+ "--video-subject",
+ "test",
+ "--video-source",
+ "wavespeed",
+ "--confirm-wavespeed-charge",
+ ]
+ )
+ self.assertEqual(cli.build_video_params(args).video_source, "wavespeed")
+
+ def test_wavespeed_confirmation_is_not_required_before_material_stage(self):
+ args = cli.parse_args(
+ [
+ "--video-subject",
+ "test",
+ "--video-source",
+ "wavespeed",
+ "--stop-at",
+ "script",
+ ]
+ )
+ self.assertEqual(args.video_source, "wavespeed")
+
+ def test_batch_wavespeed_source_uses_global_charge_confirmation(self):
+ with tempfile.TemporaryDirectory() as temp_dir:
+ manifest = Path(temp_dir) / "tasks.json"
+ manifest.write_text(
+ json.dumps([{"video_subject": "ws", "video_source": "wavespeed"}]),
+ encoding="utf-8",
+ )
+ with patch("app.services.task.start") as start:
+ rejected = cli.run_cli(
+ ["--batch-file", str(manifest), "--stop-at", "materials"]
+ )
+ self.assertEqual(rejected, 2)
+ start.assert_not_called()
+
+ with (
+ patch(
+ "app.services.task.start",
+ return_value={"state": 1, "materials": ["ok"]},
+ ) as start,
+ patch("app.utils.utils.get_uuid", return_value="task-ws"),
+ redirect_stdout(io.StringIO()),
+ ):
+ accepted = cli.run_cli(
+ [
+ "--batch-file",
+ str(manifest),
+ "--stop-at",
+ "materials",
+ "--confirm-wavespeed-charge",
+ ]
+ )
+
+ self.assertEqual(accepted, 0)
+ start.assert_called_once()
+
def test_ofox_video_source_requires_explicit_charge_confirmation(self):
with self.assertRaises(SystemExit) as raised:
cli.parse_args(