fixed bugs

This commit is contained in:
2026-09-13 12:58:45 +08:00
parent f810cfedd4
commit 5328898971
7 changed files with 233 additions and 61 deletions

View File

@@ -481,9 +481,13 @@ def create_app(
media_path = service_settings.videos_dir / row["stored_filename"]
if not media_path.is_file():
raise HTTPException(status_code=404, detail="Stored video file is missing.")
media_type = row.get("content_type") or "video/mp4"
if not str(media_type).lower().startswith("video/"):
guessed = mimetypes.guess_type(str(row.get("stored_filename") or ""))[0]
media_type = guessed if guessed and guessed.lower().startswith("video/") else "video/mp4"
return FileResponse(
media_path,
media_type=row["content_type"],
media_type=media_type,
headers={"Accept-Ranges": "bytes", "Cache-Control": "public, max-age=3600"},
)