diff --git a/src/lib/client/downloader.ts b/src/lib/client/downloader.ts index cb2d821..c75c651 100644 --- a/src/lib/client/downloader.ts +++ b/src/lib/client/downloader.ts @@ -1,21 +1,21 @@ const createAnchorElement = (url: string, filename: string): HTMLAnchorElement => { - const anchor = document.createElement('a'); - anchor.href = url; - anchor.download = filename; - return anchor -} + const anchor = document.createElement('a'); + anchor.href = url; + anchor.download = filename; + return anchor; +}; export const download = async (url: string, filename: string) => { - const response = await fetch(url); + const response = await fetch(url); - if (!response.ok) { - throw new Error('Network response was not ok'); - } + if (!response.ok) { + throw new Error('Network response was not ok'); + } - const blob = await response.blob(); - const objectURL = window.URL.createObjectURL(blob); - const anchor = createAnchorElement(url, filename) - document.body.appendChild(anchor); - anchor.click(); - anchor.remove(); - window.URL.revokeObjectURL(objectURL); -} + const blob = await response.blob(); + const objectURL = window.URL.createObjectURL(blob); + const anchor = createAnchorElement(url, filename); + document.body.appendChild(anchor); + anchor.click(); + anchor.remove(); + window.URL.revokeObjectURL(objectURL); +}; diff --git a/src/lib/components/DownloadManager.svelte b/src/lib/components/DownloadManager.svelte index 761f47f..efe3bc0 100644 --- a/src/lib/components/DownloadManager.svelte +++ b/src/lib/components/DownloadManager.svelte @@ -52,12 +52,16 @@ {#if visible} -
-
+
+

- Downloading {filename} + Downloading {filename}

-
+
{ return { value: f, label: f.toUpperCase() }; @@ -29,13 +29,13 @@ }; const dismiss = () => { - unmount(downloadManager) - } + unmount(downloadManager); + }; const onClick = async (evt) => { evt.preventDefault(); - const props = $state( { url: href }); + const props = $state({ url: href }); downloadManager = mount(DownloadManager, { target: document.body, props, events: { dismiss } }); link = ''; diff --git a/src/routes/download/+server.ts b/src/routes/download/+server.ts index 94a8c35..9b62aba 100644 --- a/src/routes/download/+server.ts +++ b/src/routes/download/+server.ts @@ -54,7 +54,6 @@ export const GET: RequestHandler = async ({ url }) => { logger.error('Error fetching metadata:'); throw error(500, 'Failed to fetch video metadata'); } - try { // Stream video/audio