利用 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): skip background music removed during listing
Rudy Celeklif3ace0606459
diff --git a/app/controllers/v1/video.py b/app/controllers/v1/video.pyindex b401a7e3..48301a13 100644--- a/app/controllers/v1/video.py+++ b/app/controllers/v1/video.py@@ -366,10 +366,15 @@ def get_bgm_list(request: Request):bgm_list = []for file in bgm_service.list_bgm_files():filename = os.path.basename(file)+ try:+ size = os.path.getsize(file)+ except OSError as exc:+ logger.warning(f"skip unavailable background music: name={filename}, error={exc}")+ continuebgm_list.append({"name": filename,- "size": os.path.getsize(file),+ "size": size,# 只返回文件名,避免把服务器绝对路径暴露给调用方。服务端会# 在 storage/bgm 和 resource/songs 两个白名单目录中重新解析。"file": filename,diff --git a/test/services/test_bgm_list_race.py b/test/services/test_bgm_list_race.pynew file mode 100644index 00000000..cfef46d8--- /dev/null+++ b/test/services/test_bgm_list_race.py@@ -0,0 +1,13 @@+from types import SimpleNamespace+from unittest.mock import patch+from app.controllers.v1 import video as controller++def test_bgm_picker_survives_file_removed_during_listing():+ def size(filename):+ if filename == "/bgm/deleted.mp3":+ raise FileNotFoundError(filename)+ return 42+ with (patch.object(controller.bgm_service, "list_bgm_files", return_value=["/bgm/deleted.mp3", "/bgm/music.mp3"]),+ patch.object(controller.os.path, "getsize", side_effect=size)):+ result = controller.get_bgm_list(SimpleNamespace(headers={}))+ assert result["data"]["files"] == [{"name": "music.mp3", "size": 42, "file": "music.mp3"}]