利用 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): use artifact media types (#1489)
Rudy Mizrahi Celekli0213f78e75d6
diff --git a/app/controllers/v1/video.py b/app/controllers/v1/video.pyindex 6ceac08f..0246ae53 100644--- a/app/controllers/v1/video.py+++ b/app/controllers/v1/video.py@@ -1,3 +1,4 @@+import mimetypesimport osimport pathlibimport shutil@@ -549,9 +550,9 @@ async def download_video(request: Request, file_path: str):video_path = _resolve_path_within_directory(tasks_dir, file_path, request_id)file_path = pathlib.Path(video_path)filename = file_path.name- extension = file_path.suffix+ media_type, _ = mimetypes.guess_type(filename)return FileResponse(path=video_path,filename=filename,- media_type=f"video/{extension[1:]}",+ media_type=media_type or "application/octet-stream",)diff --git a/test/services/test_artifact_download_mime.py b/test/services/test_artifact_download_mime.pynew file mode 100644index 00000000..f781ee9e--- /dev/null+++ b/test/services/test_artifact_download_mime.py@@ -0,0 +1,35 @@+from pathlib import Path+from tempfile import TemporaryDirectory+from unittest.mock import patch++import pytest+from fastapi.testclient import TestClient++from app import asgi+from app.config import config+from app.controllers.v1 import video as controller++[email protected]('filename,expected', [+ ('audio.mp3', 'audio/mpeg'),+ ('audio.wav', ('audio/x-wav', 'audio/wav', 'audio/vnd.wave')),+ ('subtitle.srt', ('application/x-subrip', 'text/plain')),+ ('script.json', 'application/json'),+ ('final-1.mp4', 'video/mp4'),+ ('artifact.unknown-mpt-extension', 'application/octet-stream'),+])+def test_download_reports_artifact_media_type(filename, expected):+ with TemporaryDirectory() as directory:+ task_dir = Path(directory, 'task-1')+ task_dir.mkdir()+ payload = b'isolated download fixture'+ (task_dir / filename).write_bytes(payload)+ with (+ patch.dict(config.app, {'api_key': ''}),+ patch.object(controller.utils, 'task_dir', return_value=directory),+ ):+ response = TestClient(asgi.get_application()).get(f'/api/v1/download/task-1/{filename}')+ assert response.status_code == 200+ assert response.content == payload+ assert response.headers['content-type'].split(';')[0] in (expected if isinstance(expected, tuple) else (expected,))+ assert filename in response.headers['content-disposition']