diff --git a/app.py b/app.py index 7c74ff0..17de262 100644 --- a/app.py +++ b/app.py @@ -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