利用 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): include asset query in video cache identity
Rudy Celeklifd58455240bd
diff --git a/app/services/material.py b/app/services/material.pyindex b7796af6..a10efbd2 100644--- a/app/services/material.py+++ b/app/services/material.py@@ -1093,8 +1093,11 @@ def save_video(video_url: str, save_dir: str = "") -> str:if not os.path.exists(save_dir):os.makedirs(save_dir)- url_without_query = video_url.split("?")[0]- url_hash = utils.md5(url_without_query)+ # Query parameters can identify the asset itself (for example,+ # /download?file_id=123). Dropping the query makes unrelated paid videos+ # share one cache entry and silently reuse the first scene. Fragments are+ # not sent in HTTP requests, so they do not affect the downloaded bytes.+ url_hash = utils.md5(video_url.split("#", 1)[0])video_id = f"vid-{url_hash}"video_path = f"{save_dir}/{video_id}.mp4"diff --git a/test/services/test_material.py b/test/services/test_material.pyindex d4990b44..d4ee40c9 100644--- a/test/services/test_material.py+++ b/test/services/test_material.py@@ -785,6 +785,39 @@ class TestMaterialTlsVerification(unittest.TestCase):self.assertLessEqual(response.chunk_size, 1024 * 1024)self.assertTrue(get.call_args.kwargs["stream"])+ def test_save_video_distinguishes_assets_in_download_query(self):+ """Different paid assets can share a /download path and differ only by query."""+ first_url = "https://cdn.example.com/download?file_id=first"+ second_url = "https://cdn.example.com/download?file_id=second"++ class FakeVideoFileClip:+ duration = 1+ fps = 24++ def __init__(self, path):+ pass++ def close(self):+ pass++ with tempfile.TemporaryDirectory() as temp_dir:+ with patch(+ "app.services.material.requests.get",+ side_effect=[+ _FakeVideoDownloadResponse(b"first generated scene"),+ _FakeVideoDownloadResponse(b"second generated scene"),+ ],+ ) as get, patch("app.services.material.VideoFileClip", FakeVideoFileClip):+ first_path = material.save_video(first_url, save_dir=temp_dir)+ second_path = material.save_video(second_url, save_dir=temp_dir)+ cached_path = material.save_video(first_url, save_dir=temp_dir)++ self.assertNotEqual(first_path, second_path)+ self.assertEqual(Path(first_path).read_bytes(), b"first generated scene")+ self.assertEqual(Path(second_path).read_bytes(), b"second generated scene")+ self.assertEqual(cached_path, first_path)+ self.assertEqual(get.call_count, 2)+def test_save_video_cleans_partial_stream_when_download_fails(self):class FailingResponse(_FakeVideoDownloadResponse):def __init__(self):