Fix again

This commit is contained in:
MMaker 2025-02-27 15:56:20 -05:00
parent 7cbc5f84c9
commit bca73594f5
Signed by: mmaker
GPG Key ID: CCE79B8FEDA40FB2

7
app.py
View File

@ -41,7 +41,7 @@ placeholder_video = None
PLACEHOLDER_VIDEO_PATH = os.environ.get('NICONICOGAY_PLACEHOLDER_VIDEO', 'placeholder.mp4')
try:
with open(PLACEHOLDER_VIDEO_PATH, 'rb') as f:
placeholder_video = BytesIO(f.read())
placeholder_video = f.read()
logger.debug("Loaded placeholder video")
except FileNotFoundError:
logger.warning(f"Placeholder video file '{PLACEHOLDER_VIDEO_PATH}' not found")
@ -305,9 +305,8 @@ def cdn_redirect(video_id):
return Response("", status=302, headers={"Location": cdn_url})
logger.info(f"{video_id}: Video not found in CDN, returning placeholder")
placeholder_video.seek(0)
response = make_response(send_file(placeholder_video, mimetype="video/mp4"))
response.headers['Content-Length'] = str(placeholder_video.getbuffer().nbytes)
response = make_response(send_file(BytesIO(placeholder_video), mimetype="video/mp4"))
response.headers['Content-Length'] = str(len(placeholder_video))
return response