Fix wrong Content-Type for m4a/flac/ogg/wav/aac track streams

mimetypes on the backend image doesn't recognize these extensions, so
every non-mp3 track streamed as audio/mpeg — wrong codec hint, breaks
playback in strict browsers. Add an explicit fallback map.
This commit is contained in:
Myron Blair
2026-07-26 20:40:59 -05:00
parent cf31a14ae1
commit 64d8945460
+2 -1
View File
@@ -1534,7 +1534,8 @@ async def stream_track(
if not file_path.is_file(): raise HTTPException(status_code=404, detail="File missing on disk")
file_size = file_path.stat().st_size
content_type = mimetypes.guess_type(str(file_path))[0] or "audio/mpeg"
_audio_mime_fallback = {".m4a": "audio/mp4", ".flac": "audio/flac", ".ogg": "audio/ogg", ".wav": "audio/wav", ".aac": "audio/aac"}
content_type = mimetypes.guess_type(str(file_path))[0] or _audio_mime_fallback.get(file_path.suffix.lower(), "audio/mpeg")
range_header = request.headers.get("range") or request.headers.get("Range")
if range_header and range_header.startswith("bytes="):
try: