From 6913e74f84b7fc89b9939a09d28a5f27764c7c98 Mon Sep 17 00:00:00 2001 From: "juancarlos.cavero" Date: Sun, 21 Dec 2025 23:38:50 +0100 Subject: [PATCH] fix downloads --- dashboard/src/components/ResultCard.jsx | 26 +++++++++++++++++++++---- main.py | 1 - 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/dashboard/src/components/ResultCard.jsx b/dashboard/src/components/ResultCard.jsx index dbcec7c..cd19fdb 100644 --- a/dashboard/src/components/ResultCard.jsx +++ b/dashboard/src/components/ResultCard.jsx @@ -143,13 +143,31 @@ export default function ResultCard({ clip, index, jobId, uploadPostKey, uploadUs > Post - { + e.preventDefault(); + try { + const response = await fetch(videoUrl); + if (!response.ok) throw new Error('Download failed'); + const blob = await response.blob(); + const url = window.URL.createObjectURL(blob); + const a = document.createElement('a'); + a.style.display = 'none'; + a.href = url; + a.download = `clip-${index + 1}.mp4`; + document.body.appendChild(a); + a.click(); + window.URL.revokeObjectURL(url); + document.body.removeChild(a); + } catch (err) { + console.error('Download error:', err); + window.open(videoUrl, '_blank'); + } + }} className="col-span-1 py-2 bg-white/5 hover:bg-white/10 text-zinc-300 hover:text-white rounded-lg text-xs font-medium transition-colors flex items-center justify-center gap-2 border border-white/5 truncate px-2" > Download - + diff --git a/main.py b/main.py index 5a5a568..2ab9e97 100644 --- a/main.py +++ b/main.py @@ -463,7 +463,6 @@ def download_youtube_video(url, output_dir="."): try: with open(cookies_path, 'w') as f: f.write(cookies_env) - print(f"✅ Cookies written to {cookies_path}") except Exception as e: print(f"⚠️ Failed to write cookies file: {e}") cookies_path = None