Update download method
All checks were successful
Bump deps (only minor versions) / ci (push) Successful in 18s

This commit is contained in:
0d0 2025-04-19 17:58:24 +02:00
parent 08578eef0b
commit 5bcbfc70ec
5 changed files with 31 additions and 28 deletions

View file

@ -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);
};

View file

@ -52,12 +52,16 @@
</script>
{#if visible}
<div class="fixed inset-0 z-50 flex items-center justify-center bg-black/80 backdrop-blur-sm font-mono">
<div class="w-[90%] max-w-sm rounded-2xl border border-green-400 bg-[#000f00] p-6 text-green-300 shadow-2xl text-sm">
<div
class="fixed inset-0 z-50 flex items-center justify-center bg-black/80 font-mono backdrop-blur-sm"
>
<div
class="w-[90%] max-w-sm rounded-2xl border border-green-400 bg-[#000f00] p-6 text-sm text-green-300 shadow-2xl"
>
<p class="mb-2 text-center text-cyan-300">
Downloading <span class="text-green-400 font-semibold">{filename}</span>
Downloading <span class="font-semibold text-green-400">{filename}</span>
</p>
<div class="w-full h-4 rounded-md bg-black border border-green-500 overflow-hidden">
<div class="h-4 w-full overflow-hidden rounded-md border border-green-500 bg-black">
<div
class="h-full bg-gradient-to-r from-green-400 to-green-600 transition-all duration-300"
style="width: {progress}%"

View file

@ -17,8 +17,8 @@ export async function getYouTubeMetadata(link: string) {
dumpSingleJson: true,
noCheckCertificates: true,
noWarnings: true,
preferFreeFormats: true,
}
preferFreeFormats: true
};
if (HTTPS_PROXY) {
options.proxy = HTTPS_PROXY;