利用 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(api): omit Redis auth segment when password is not configured
MihirPc88e864a0d3e
diff --git a/app/controllers/v1/video.py b/app/controllers/v1/video.pyindex 00ef176b..82a5c42f 100644--- a/app/controllers/v1/video.py+++ b/app/controllers/v1/video.py@@ -48,7 +48,13 @@ _redis_password = config.app.get("redis_password", None)_max_concurrent_tasks = config.app.get("max_concurrent_tasks", 5)_max_queued_tasks = config.app.get("max_queued_tasks", 100)-redis_url = f"redis://:{_redis_password}@{_redis_host}:{_redis_port}/{_redis_db}"++def _build_redis_url(host: str, port: int, db: int, password: str | None) -> str:+ auth = f":{password}@" if password else ""+ return f"redis://{auth}{host}:{port}/{db}"+++redis_url = _build_redis_url(_redis_host, _redis_port, _redis_db, _redis_password)# 根据配置选择合适的任务管理器if _enable_redis:task_manager = RedisTaskManager(diff --git a/test/services/test_controller_video.py b/test/services/test_controller_video.pyindex 5024a106..4c222f90 100644--- a/test/services/test_controller_video.py+++ b/test/services/test_controller_video.py@@ -541,5 +541,28 @@ class TestVideoControllerFiles(unittest.TestCase):self.assertEqual(response.media_type, "video/mp4")+class TestBuildRedisUrl(unittest.TestCase):+ def test_no_password_omits_auth_segment(self):+ """None and empty-string passwords must not embed a literal 'None' or ':@'."""+ from app.controllers.v1.video import _build_redis_url++ self.assertEqual(+ _build_redis_url("localhost", 6379, 0, None),+ "redis://localhost:6379/0",+ )+ self.assertEqual(+ _build_redis_url("localhost", 6379, 0, ""),+ "redis://localhost:6379/0",+ )++ def test_password_is_included_in_url(self):+ from app.controllers.v1.video import _build_redis_url++ self.assertEqual(+ _build_redis_url("redis-host", 6380, 1, "s3cr3t"),+ "redis://:s3cr3t@redis-host:6380/1",+ )++if __name__ == "__main__":unittest.main()