updates
Build and Push Docker Images / build-and-push (push) Successful in 22s

This commit is contained in:
2026-02-11 23:11:41 +01:00
parent 016e0cee0c
commit e92ccd757a
3 changed files with 52 additions and 27 deletions
+12 -8
View File
@@ -158,23 +158,27 @@ class IPTVHandler(BaseHTTPRequestHandler):
def send_stream(self, path_param: str):
"""Stream a video file. path is relative to /movies or /series."""
from iptv.streamer import (
path_to_absolute,
get_preferred_audio_stream_index,
stream_file_with_preferred_audio,
)
from iptv.streamer import path_to_absolute, try_remux_preferred_audio
abs_path = path_to_absolute(path_param)
if abs_path is None:
self.send_error(404, "File not found")
return
audio_idx = get_preferred_audio_stream_index(abs_path)
if audio_idx is not None:
remux = try_remux_preferred_audio(abs_path)
if remux is not None:
first, rest = remux
self.send_response(200)
self.send_header("Content-Type", "video/mp4")
self.send_header("Cache-Control", "no-cache")
self.end_headers()
stream_file_with_preferred_audio(abs_path, self.wfile)
try:
self.wfile.write(first)
self.wfile.flush()
for chunk in rest:
self.wfile.write(chunk)
self.wfile.flush()
except (BrokenPipeError, ConnectionResetError, OSError):
pass
return
content_type, _ = mimetypes.guess_type(str(abs_path))
content_type = content_type or "video/mp4"