利用 AI 大模型和自动化工作流,根据主题或关键词一键生成高清短视频。Generate HD short videos from a topic or keyword with an automated AI workflow.
Python ai-video-generatorcontent-creationffmpeginstagram-reelsllmpythonshort-videosubtitlestext-to-speechtiktokvideo-automationvideo-workflowworkflow-automationyoutube-shorts
fix(material): fall back from infinite AI video duration bounds
Rudy Celeklib742c1408ade
diff --git a/app/services/muapi.py b/app/services/muapi.pyindex 02feff0d..73de5e47 100644--- a/app/services/muapi.py+++ b/app/services/muapi.py@@ -124,7 +124,9 @@ def _duration_bounds() -> tuple[int, int]:def read(key: str, default: int) -> int:try:value = int(config.app.get(key, default))- except (TypeError, ValueError):+ except (TypeError, ValueError, OverflowError):+ # TOML accepts `inf`; int(inf) raises OverflowError, which is not+ # a provider error and would abort the task with a traceback.return defaultreturn value if value >= 1 else defaultdiff --git a/app/services/ofox.py b/app/services/ofox.pyindex 63aafabe..d261b894 100644--- a/app/services/ofox.py+++ b/app/services/ofox.py@@ -142,7 +142,9 @@ def _duration_bounds() -> tuple[int, int]:def read(key: str, default: int) -> int:try:value = int(config.app.get(key, default))- except (TypeError, ValueError):+ except (TypeError, ValueError, OverflowError):+ # TOML accepts `inf`; int(inf) raises OverflowError, which is not+ # a provider error and would abort the task with a traceback.return defaultreturn value if value >= 1 else defaultdiff --git a/app/services/volcengine_seedance.py b/app/services/volcengine_seedance.pyindex ba538c99..6744e383 100644--- a/app/services/volcengine_seedance.py+++ b/app/services/volcengine_seedance.py@@ -123,7 +123,9 @@ def _duration_bounds() -> tuple[int, int]:def read(key: str, default: int) -> int:try:value = int(config.app.get(key, default))- except (TypeError, ValueError):+ except (TypeError, ValueError, OverflowError):+ # TOML accepts `inf`; int(inf) raises OverflowError, which is not+ # a provider error and would abort the task with a traceback.return defaultreturn value if value >= 1 else defaultdiff --git a/test/services/test_video_provider_duration_bounds.py b/test/services/test_video_provider_duration_bounds.pynew file mode 100644index 00000000..57bbf0fe--- /dev/null+++ b/test/services/test_video_provider_duration_bounds.py@@ -0,0 +1,35 @@+import importlib+from unittest.mock import patch++import pytest++from app.config import config+++ "module_name, prefix",+ [+ ("app.services.ofox", "ofox"),+ ("app.services.muapi", "muapi"),+ ("app.services.volcengine_seedance", "volcengine_seedance"),+ ],+)[email protected]("bad_value", [float("inf"), float("-inf"), float("nan")])+def test_nonfinite_configured_duration_bounds_fall_back_to_defaults(+ module_name, prefix, bad_value+):+ # TOML can express inf/nan. Invalid bounds must use the documented+ # defaults instead of escaping as a raw OverflowError.+ module = importlib.import_module(module_name)+ settings = {+ f"{prefix}_min_duration": bad_value,+ f"{prefix}_max_duration": bad_value,+ }++ with patch.dict(config.app, settings):+ bounds = module._duration_bounds()++ assert bounds == (+ module.DEFAULT_MIN_DURATION_SECONDS,+ max(module.DEFAULT_MIN_DURATION_SECONDS, module.DEFAULT_MAX_DURATION_SECONDS),+ )