From ba8d79910c7aeda736db8f8e5a541a0a1af5ff96 Mon Sep 17 00:00:00 2001 From: Samive Date: Wed, 8 Apr 2026 10:45:10 +0800 Subject: [PATCH] Update to include able resume download activity --- web/backend/main.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/web/backend/main.py b/web/backend/main.py index 8f18f0001..e606349eb 100644 --- a/web/backend/main.py +++ b/web/backend/main.py @@ -62,7 +62,7 @@ async def index(): @app.post("/info") async def get_info(req: InfoRequest): - ydl_opts = {"quiet": True, "no_warnings": True, "skip_download": True} + ydl_opts = {"quiet": True, "no_warnings": True, "skip_download": True, "outtmpl": output_template, "merge_output_format": "mp4", "postprocessors": [{"key": "FFmpegVideoConvertor","preferedformat": "mp4"}]} info = None try: with yt_dlp.YoutubeDL(ydl_opts) as ydl: @@ -258,12 +258,15 @@ async def serve_file(file_id: str): filepath.unlink(missing_ok=True) _progress.pop(file_id, None) - return StreamingResponse( - iterfile(), - media_type="video/mp4", + from fastapi.responses import FileResponse + + return FileResponse( + path=filepath, + media_type=media_type, + filename=filename_ascii, headers={ - "Content-Disposition": f"attachment; filename=\"{filename_ascii}\"; filename*=UTF-8''{filename_encoded}", - }, + "Content-Disposition": f"attachment; filename*=UTF-8''{filename_encoded}" + } )