From 7fcc5e344a02f85067e95c576162e9e119bb4943 Mon Sep 17 00:00:00 2001 From: suricata Date: Fri, 16 Jan 2026 13:45:22 +0000 Subject: [PATCH] auto download --- app/pages/index.vue | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/app/pages/index.vue b/app/pages/index.vue index 7191e8e..8dc3962 100644 --- a/app/pages/index.vue +++ b/app/pages/index.vue @@ -8,9 +8,11 @@ const url = ref(""); const in_url = ref(""); + const file_dwnl = ref(""); + const music_params_schema = z.object({ song: z.string("Song name required"), - artist: z.string("Artist name required"), + artist: z.string().optional(), album: z.string().optional() }) @@ -30,6 +32,7 @@ else video.value = 0 } + async function start_conversion(event: FormSubmitEvent) { return fetch("/convert", { method: "POST", @@ -38,15 +41,27 @@ }, body: JSON.stringify({ url: url.value, - name: music_params.song, + song: music_params.song, artist: music_params.artist, album: music_params.album }) - }).then(r => { - console.log(r.status) + }).then(async r => { + //console.log(r.status) if(r.status == 401) window.location.href = "/login" + if(r.ok) { + const data = await r.json(); // resolves to { file: "my_audio.mp3" } + const file = data.file; + file_dwnl.value = `/download/${file}`; + const a = document.createElement("a"); + a.href = file_dwnl.value; + a.download = file; // sets suggested filename + document.body.appendChild(a); // must append first + a.click(); // triggers download + a.remove(); + } }) + } @@ -75,19 +90,22 @@ - + - + - +
Convert to MP3
+
+ Download +