利用 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(redis): encode queue URLs (#1412)
Rudy Mizrahi Celekli2319167bfff0
diff --git a/app/controllers/v1/video.py b/app/controllers/v1/video.pyindex 862fdf51..0bac92e7 100644--- a/app/controllers/v1/video.py+++ b/app/controllers/v1/video.py@@ -3,6 +3,7 @@ import osimport pathlibimport shutilfrom typing import Union+from urllib.parse import quotefrom fastapi import BackgroundTasks, Depends, Path, Query, Request, UploadFilefrom fastapi.params import File@@ -50,8 +51,14 @@ _max_queued_tasks = config.app.get("max_queued_tasks", 100)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}"+ # Passwords are URL userinfo. Escape reserved characters so Redis receives+ # the exact configured secret rather than parsing part of it as a host,+ # port, path, query, or fragment.+ auth = f":{quote(password, safe='')}@" if password else ""+ # URL authorities require brackets around IPv6 literals. RedisState also+ # accepts a plain IPv6 host, so keep the queue client compatible with it.+ url_host = f"[{host}]" if ":" in host and not host.startswith("[") else host+ return f"redis://{auth}{url_host}:{port}/{db}"redis_url = _build_redis_url(_redis_host, _redis_port, _redis_db, _redis_password)diff --git a/test/services/test_controller_video.py b/test/services/test_controller_video.pyindex 4fa97792..24eac1ba 100644--- a/test/services/test_controller_video.py+++ b/test/services/test_controller_video.py@@ -8,6 +8,7 @@ from pathlib import Pathfrom types import SimpleNamespacefrom unittest.mock import MagicMock, patch+import redisfrom fastapi.testclient import TestClientfrom app import asgi@@ -706,6 +707,27 @@ class TestBuildRedisUrl(unittest.TestCase):"redis://:s3cr3t@redis-host:6380/1",)+ def test_reserved_characters_in_password_round_trip_through_redis_url(self):+ from app.controllers.v1.video import _build_redis_url++ password = "p@ss:/?#% word"+ url = _build_redis_url("redis-host", 6380, 1, password)++ self.assertEqual(+ redis.Redis.from_url(url).connection_pool.connection_kwargs["password"],+ password,+ )++ def test_ipv6_host_round_trips_through_redis_url(self):+ from app.controllers.v1.video import _build_redis_url++ url = _build_redis_url("::1", 6380, 1, None)+ connection = redis.Redis.from_url(url).connection_pool.connection_kwargs++ self.assertEqual(connection["host"], "::1")+ self.assertEqual(connection["port"], 6380)+ self.assertEqual(connection["db"], 1)+if __name__ == "__main__":unittest.main()