Compare commits
24 commits
Author | SHA1 | Date | |
---|---|---|---|
e3c0c7d1f9 | |||
d43db45617 | |||
67e521b7b4 | |||
3dc834daf0 | |||
5bcbfc70ec | |||
08578eef0b | |||
e82c027ad9 | |||
4303614237 | |||
4bf9d97345 | |||
99263fd14c | |||
|
691e294546 | ||
|
885c802da6 | ||
|
6d0d7ccecc | ||
|
ff5cef233d | ||
|
2b81cb2fa5 | ||
|
9ffcd5f596 | ||
|
1bd6d90814 | ||
|
c46189ff83 | ||
|
c416918a1a | ||
|
7a3bf1fb45 | ||
|
cd8a4c4d69 | ||
9c7f7eace1 | |||
5066c3ba7a | |||
a833c43713 |
12 changed files with 569 additions and 431 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
NODE_ENV=development
|
||||||
HOST=0.0.0.0
|
HOST=0.0.0.0
|
||||||
ORIGIN=https://dl.emersa.it
|
ORIGIN=https://dl.emersa.it
|
||||||
YTDLP_PATH=./yt-dlp
|
YTDLP_PATH=./yt-dlp
|
||||||
|
|
|
@ -33,6 +33,7 @@ jobs:
|
||||||
echo "HOST=0.0.0.0" >> .env
|
echo "HOST=0.0.0.0" >> .env
|
||||||
echo "ORIGIN=https://dl.emersa.it" >> .env
|
echo "ORIGIN=https://dl.emersa.it" >> .env
|
||||||
echo "PUBLIC_VERSION=$(cat package.json | jq .version)" >> .env
|
echo "PUBLIC_VERSION=$(cat package.json | jq .version)" >> .env
|
||||||
|
echo "NODE_ENV=production" >> .env
|
||||||
npm run build
|
npm run build
|
||||||
cp package* build/
|
cp package* build/
|
||||||
cp .env build/
|
cp .env build/
|
||||||
|
|
602
package-lock.json
generated
602
package-lock.json
generated
File diff suppressed because it is too large
Load diff
28
package.json
28
package.json
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "dl.emersa.it",
|
"name": "dl.emersa.it",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.9.3-c",
|
"version": "1.0.0-b",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite dev",
|
"dev": "vite dev",
|
||||||
|
@ -16,32 +16,32 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/compat": "^1.2.8",
|
"@eslint/compat": "^1.2.8",
|
||||||
"@eslint/js": "^9.24.0",
|
"@eslint/js": "^9.25.0",
|
||||||
"@sveltejs/adapter-node": "^5.2.12",
|
"@sveltejs/adapter-node": "^5.2.12",
|
||||||
"@sveltejs/kit": "^2.20.4",
|
"@sveltejs/kit": "^2.20.7",
|
||||||
"@sveltejs/vite-plugin-svelte": "^5.0.3",
|
"@sveltejs/vite-plugin-svelte": "^5.0.3",
|
||||||
"@tailwindcss/vite": "^4.1.3",
|
"@tailwindcss/vite": "^4.1.4",
|
||||||
"eslint": "^9.24.0",
|
"eslint": "^9.25.0",
|
||||||
"eslint-config-prettier": "^10.1.1",
|
"eslint-config-prettier": "^10.1.2",
|
||||||
"eslint-plugin-svelte": "^3.5.1",
|
"eslint-plugin-svelte": "^3.5.1",
|
||||||
"globals": "^16.0.0",
|
"globals": "^16.0.0",
|
||||||
"mdsvex": "^0.12.3",
|
"mdsvex": "^0.12.3",
|
||||||
"prettier": "^3.5.3",
|
"prettier": "^3.5.3",
|
||||||
"prettier-plugin-svelte": "^3.3.3",
|
"prettier-plugin-svelte": "^3.3.3",
|
||||||
"prettier-plugin-tailwindcss": "^0.6.11",
|
"prettier-plugin-tailwindcss": "^0.6.11",
|
||||||
"svelte": "^5.25.8",
|
"svelte": "^5.28.1",
|
||||||
"svelte-check": "^4.1.5",
|
"svelte-check": "^4.1.6",
|
||||||
"sveltekit-sse": "^0.13.16",
|
"sveltekit-sse": "^0.13.18",
|
||||||
"tailwindcss": "^4.1.3",
|
"tailwindcss": "^4.1.4",
|
||||||
"typescript": "^5.8.3",
|
"typescript": "^5.8.3",
|
||||||
"typescript-eslint": "^8.29.1",
|
"typescript-eslint": "^8.30.1",
|
||||||
"vite": "^6.2.5"
|
"vite": "^6.3.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@tailwindcss/forms": "^0.5.10",
|
"@tailwindcss/forms": "^0.5.10",
|
||||||
"@tailwindcss/postcss": "^4.1.3",
|
"@tailwindcss/postcss": "^4.1.4",
|
||||||
"@tailwindcss/typography": "^0.5.16",
|
"@tailwindcss/typography": "^0.5.16",
|
||||||
"@types/node": "^22.14.0",
|
"@types/node": "^22.14.1",
|
||||||
"winston": "^3.17.0",
|
"winston": "^3.17.0",
|
||||||
"youtube-dl-exec": "^3.0.20"
|
"youtube-dl-exec": "^3.0.20"
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,14 +7,11 @@
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
%sveltekit.head%
|
%sveltekit.head%
|
||||||
<style>
|
<style>
|
||||||
@font-face {
|
* {
|
||||||
font-family: 'Press Start 2P';
|
font-family: 'Fira Code', monospace;
|
||||||
src: url('/fonts/PressStart2P-Regular.ttf');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
background: black; /* Fallback */
|
background: black; /* Fallback */
|
||||||
font-family: 'Press Start 2P', sans-serif;
|
|
||||||
color: #37ff1456; /* Retro green text */
|
color: #37ff1456; /* Retro green text */
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
21
src/lib/client/downloader.ts
Normal file
21
src/lib/client/downloader.ts
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
const createAnchorElement = (url: string, filename: string): HTMLAnchorElement => {
|
||||||
|
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);
|
||||||
|
|
||||||
|
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);
|
||||||
|
};
|
|
@ -1,3 +1,73 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
let props = $props();
|
import { onMount } from 'svelte';
|
||||||
|
let { url, dismiss } = $props();
|
||||||
|
|
||||||
|
let visible = $state(false);
|
||||||
|
let progress = $state(0);
|
||||||
|
let filename = $state('');
|
||||||
|
onMount(async () => {
|
||||||
|
if (!url) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
visible = true;
|
||||||
|
|
||||||
|
const response = await fetch(url);
|
||||||
|
if (!response.ok) throw new Error('Download failed');
|
||||||
|
|
||||||
|
const contentDisposition: string = response?.headers?.get('content-disposition');
|
||||||
|
filename = contentDisposition.split('filename=')[1];
|
||||||
|
const contentLength: number = Number(response?.headers?.get('content-length'));
|
||||||
|
const reader = response?.body?.getReader();
|
||||||
|
const chunks: Uint8Array[] = [];
|
||||||
|
let receivedLength = 0;
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
const { done, value }: ReadableStreamReadResult<Uint8Array> = await reader.read();
|
||||||
|
if (done) break;
|
||||||
|
if (value) {
|
||||||
|
chunks.push(value);
|
||||||
|
receivedLength += value.length;
|
||||||
|
progress = Math.round((receivedLength / contentLength) * 100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const blob = new Blob(chunks);
|
||||||
|
const downloadUrl = URL.createObjectURL(blob);
|
||||||
|
|
||||||
|
const a = document.createElement('a');
|
||||||
|
a.href = downloadUrl;
|
||||||
|
a.download = filename;
|
||||||
|
a.click();
|
||||||
|
|
||||||
|
URL.revokeObjectURL(downloadUrl);
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
visible = false;
|
||||||
|
}, 1500); // auto-dismiss
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
visible = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
{#if visible}
|
||||||
|
<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="font-semibold text-green-400">{filename}</span>
|
||||||
|
</p>
|
||||||
|
<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}%"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<p class="mt-2 text-center text-pink-400">{progress}%</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
|
@ -3,7 +3,7 @@ import winston from 'winston';
|
||||||
import { dev } from '$app/environment';
|
import { dev } from '$app/environment';
|
||||||
|
|
||||||
export const logger = winston.createLogger({
|
export const logger = winston.createLogger({
|
||||||
level: dev ? 'debug' : 'error',
|
level: import.meta.env.DEV ? 'debug' : 'error',
|
||||||
format: winston.format.json(),
|
format: winston.format.json(),
|
||||||
transports: [new winston.transports.Console()]
|
transports: [new winston.transports.Console()]
|
||||||
});
|
});
|
||||||
|
|
|
@ -5,7 +5,7 @@ import supportedFormats from '$lib/common/supportedFormats.json';
|
||||||
import { logger, mimeTypeMap } from '$lib/server/helpers';
|
import { logger, mimeTypeMap } from '$lib/server/helpers';
|
||||||
|
|
||||||
const YTDLP_PATH: string = env.YTDLP_PATH as string;
|
const YTDLP_PATH: string = env.YTDLP_PATH as string;
|
||||||
const HTTPS_PROXY: string = env.v as string;
|
const HTTPS_PROXY: string = env.HTTPS_PROXY as string;
|
||||||
|
|
||||||
export const ytdl = create(YTDLP_PATH);
|
export const ytdl = create(YTDLP_PATH);
|
||||||
|
|
||||||
|
@ -13,13 +13,18 @@ export const ytdl = create(YTDLP_PATH);
|
||||||
* Fetch YouTube metadata (title, uploader/artist)
|
* Fetch YouTube metadata (title, uploader/artist)
|
||||||
*/
|
*/
|
||||||
export async function getYouTubeMetadata(link: string) {
|
export async function getYouTubeMetadata(link: string) {
|
||||||
return await ytdl(link, {
|
const options = {
|
||||||
dumpSingleJson: true,
|
dumpSingleJson: true,
|
||||||
noCheckCertificates: true,
|
noCheckCertificates: true,
|
||||||
noWarnings: true,
|
noWarnings: true,
|
||||||
preferFreeFormats: true,
|
preferFreeFormats: true
|
||||||
proxy: HTTPS_PROXY ? HTTPS_PROXY : ''
|
};
|
||||||
});
|
|
||||||
|
if (HTTPS_PROXY) {
|
||||||
|
options.proxy = HTTPS_PROXY;
|
||||||
|
}
|
||||||
|
|
||||||
|
return await ytdl(link, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -17,4 +17,11 @@
|
||||||
transform: rotate(180deg);
|
transform: rotate(180deg);
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media screen and (max-height: 600px) {
|
||||||
|
/* Your CSS rules here */
|
||||||
|
footer {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
import { PUBLIC_VERSION } from '$env/static/public';
|
import { PUBLIC_VERSION } from '$env/static/public';
|
||||||
import supportedFormats from '$lib/common/supportedFormats.json';
|
import supportedFormats from '$lib/common/supportedFormats.json';
|
||||||
import Loader from '$lib/components/Loader.svelte';
|
import Loader from '$lib/components/Loader.svelte';
|
||||||
import { onMount } from 'svelte';
|
import { download } from '$lib/client/downloader';
|
||||||
|
import DownloadManager from '$lib/components/DownloadManager.svelte';
|
||||||
|
import { mount, unmount } from 'svelte';
|
||||||
|
|
||||||
let source = $state('youtube');
|
let source = $state('youtube');
|
||||||
let link = $state('');
|
let link = $state('');
|
||||||
|
@ -11,9 +13,8 @@
|
||||||
let href = $state('');
|
let href = $state('');
|
||||||
let disabled = $state(true);
|
let disabled = $state(true);
|
||||||
let metadata = $state(false);
|
let metadata = $state(false);
|
||||||
let downloading = $state(false);
|
|
||||||
let logs = $state('');
|
let logs = $state('');
|
||||||
let logId = undefined;
|
let downloadManager: DownloadManager | null = null;
|
||||||
|
|
||||||
const formats = Object.keys(supportedFormats).map((f) => {
|
const formats = Object.keys(supportedFormats).map((f) => {
|
||||||
return { value: f, label: f.toUpperCase() };
|
return { value: f, label: f.toUpperCase() };
|
||||||
|
@ -27,29 +28,17 @@
|
||||||
showModal = !showModal;
|
showModal = !showModal;
|
||||||
};
|
};
|
||||||
|
|
||||||
onMount(() => {
|
const dismiss = () => {
|
||||||
document.cookie = 'downloading=0';
|
unmount(downloadManager);
|
||||||
});
|
|
||||||
|
|
||||||
const readLogs = () => {
|
|
||||||
logId = setInterval(() => {
|
|
||||||
logs += "We're downloading <br>";
|
|
||||||
}, 2000);
|
|
||||||
};
|
};
|
||||||
const onClick = () => {
|
|
||||||
let checkIterations = 0;
|
const onClick = async (evt) => {
|
||||||
|
evt.preventDefault();
|
||||||
|
|
||||||
|
const props = $state({ url: href });
|
||||||
|
downloadManager = mount(DownloadManager, { target: document.body, props, events: { dismiss } });
|
||||||
|
|
||||||
link = '';
|
link = '';
|
||||||
downloading = true;
|
|
||||||
document.cookie = 'downloading=1';
|
|
||||||
|
|
||||||
readLogs();
|
|
||||||
|
|
||||||
const id = setInterval(() => {
|
|
||||||
if (document.cookie.includes('downloading=0') || checkIterations > 3) {
|
|
||||||
downloading = false && clearInterval(id) && clearInterval(logId);
|
|
||||||
}
|
|
||||||
checkIterations++;
|
|
||||||
}, 1000);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const createAnchor = () => {
|
const createAnchor = () => {
|
||||||
|
@ -94,100 +83,104 @@
|
||||||
|
|
||||||
<div
|
<div
|
||||||
id="wrapper"
|
id="wrapper"
|
||||||
class="relative mx-auto rounded-lg bg-black p-6 text-[#00ff7f] shadow-lg sm:max-w-sm sm:border-4 sm:border-[#00ff7f] md:mt-10 md:max-w-md lg:max-w-lg 2xl:max-w-2xl"
|
class="relative mx-auto max-w-full rounded-2xl bg-black p-4 text-green-400 shadow-xl sm:max-w-sm md:max-w-md lg:max-w-lg"
|
||||||
>
|
>
|
||||||
|
<!-- Loader Overlay -->
|
||||||
<div
|
<div
|
||||||
id="loader"
|
id="loader"
|
||||||
class={[
|
class="absolute inset-0 z-10 hidden items-center justify-center bg-black/80 backdrop-blur-sm"
|
||||||
'absolute inset-0 z-10 flex items-center justify-center bg-black/20 backdrop-blur-xs',
|
|
||||||
{ downloading }
|
|
||||||
]}
|
|
||||||
>
|
>
|
||||||
<Loader />
|
<Loader />
|
||||||
{@html logs}
|
{@html logs}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Info Icon -->
|
<!-- Info Button -->
|
||||||
<button
|
<button
|
||||||
onclick={toggleModal}
|
onclick={toggleModal}
|
||||||
class="absolute top-3 right-3 text-[#ff007f] transition hover:text-[#ff3399]"
|
class="absolute top-3 right-3 text-pink-500 transition hover:text-pink-400"
|
||||||
aria-label="Open Info Modal"
|
aria-label="Open Info Modal"
|
||||||
>
|
>
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" class="h-6 w-6" viewBox="0 0 24 24">
|
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" class="h-5 w-5" viewBox="0 0 24 24">
|
||||||
<path
|
<path
|
||||||
d="M12 0C5.373 0 0 5.373 0 12c0 6.627 5.373 12 12 12s12-5.373 12-12C24 5.373 18.627 0 12 0zm.75 18h-1.5v-6h1.5v6zm0-8h-1.5V8h1.5v2z"
|
d="M12 0C5.373 0 0 5.373 0 12c0 6.627 5.373 12 12 12s12-5.373 12-12C24 5.373 18.627 0 12 0zm.75 18h-1.5v-6h1.5v6zm0-8h-1.5V8h1.5v2z"
|
||||||
/>
|
/>
|
||||||
</svg>
|
</svg>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<p id="title" class="mb-6 text-center text-[#00e5ff]">🐙 Scaricatore 🐙</p>
|
<!-- Title -->
|
||||||
<form class="space-y-6">
|
<p id="title" class="mb-4 text-center font-mono text-xl tracking-tight text-cyan-300">
|
||||||
<!-- Source selection -->
|
🐙 Scaricatore 🐙
|
||||||
<div>
|
</p>
|
||||||
<label for="source" class="mb-2 block text-[#00e5ff]"> Choose Source: </label>
|
|
||||||
<select
|
<!-- Form -->
|
||||||
id="source"
|
<form class="space-y-5 font-mono text-sm">
|
||||||
name="source"
|
<!-- Source & Format -->
|
||||||
bind:value={source}
|
<div class="flex flex-col gap-4 sm:flex-row">
|
||||||
class="w-full rounded-lg border-4 border-[#00ff7f] bg-[#001a00] px-4 py-3 text-[#00ff7f] focus:border-[#ff3399] focus:outline-none"
|
<div class="flex-1">
|
||||||
>
|
<label for="source" class="mb-1 block text-cyan-300">Source</label>
|
||||||
{#each sources as source}
|
<select
|
||||||
<option value={source.value}>{source.label}</option>
|
id="source"
|
||||||
{/each}
|
name="source"
|
||||||
</select>
|
bind:value={source}
|
||||||
|
class="w-full rounded-md border border-green-400 bg-[#000f00] px-3 py-2 text-green-300 focus:border-pink-400 focus:outline-none"
|
||||||
|
>
|
||||||
|
{#each sources as source}
|
||||||
|
<option value={source.value}>{source.label}</option>
|
||||||
|
{/each}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex-1">
|
||||||
|
<label for="format" class="mb-1 block text-cyan-300">Format</label>
|
||||||
|
<select
|
||||||
|
id="format"
|
||||||
|
name="format"
|
||||||
|
bind:value={format}
|
||||||
|
class="w-full rounded-md border border-green-400 bg-[#000f00] px-3 py-2 text-green-300 focus:border-pink-400 focus:outline-none"
|
||||||
|
>
|
||||||
|
{#each formats as format}
|
||||||
|
<option value={format.value}>{format.label}</option>
|
||||||
|
{/each}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Link Input -->
|
<!-- Video Link -->
|
||||||
<div>
|
<div>
|
||||||
<label for="link" class="mb-2 block text-[#00e5ff]"> Enter Video Link: </label>
|
<label for="link" class="mb-1 block text-cyan-300">Video Link</label>
|
||||||
<input
|
<input
|
||||||
name="link"
|
|
||||||
type="url"
|
type="url"
|
||||||
id="link"
|
id="link"
|
||||||
|
name="link"
|
||||||
bind:value={link}
|
bind:value={link}
|
||||||
required
|
required
|
||||||
placeholder="Paste your link here"
|
placeholder="https://..."
|
||||||
class="w-full rounded-lg border-4 border-[#00ff7f] bg-[#001a00] px-4 py-3 text-[#00ff7f] focus:border-[#ff3399] focus:outline-none"
|
class="w-full rounded-md border border-green-400 bg-[#000f00] px-3 py-2 text-green-300 placeholder:text-green-600 focus:border-pink-400 focus:outline-none"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Format Selection -->
|
<!-- Metadata Checkbox -->
|
||||||
<div>
|
<div class="flex items-center gap-2">
|
||||||
<label for="format" class="mb-2 block text-[#00e5ff]"> Choose Format: </label>
|
|
||||||
<select
|
|
||||||
id="format"
|
|
||||||
name="format"
|
|
||||||
bind:value={format}
|
|
||||||
class="w-full rounded-lg border-4 border-[#00ff7f] bg-[#001a00] px-4 py-3 text-[#00ff7f] focus:border-[#ff3399] focus:outline-none"
|
|
||||||
>
|
|
||||||
{#each formats as format}
|
|
||||||
<option value={format.value}>{format.label}</option>
|
|
||||||
{/each}
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Metadata -->
|
|
||||||
<div>
|
|
||||||
<label for="metadata" class="mb-2 block text-[#00e5ff]"
|
|
||||||
>Set filename (<span class="text-red-700">SLOW</span>)</label
|
|
||||||
>
|
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
id="metadata"
|
id="metadata"
|
||||||
name="metadata"
|
name="metadata"
|
||||||
bind:checked={metadata}
|
bind:checked={metadata}
|
||||||
class="rounded-lg border-4 border-[#00ff7f] bg-[#001a00] px-4 py-3 text-[#00ff7f] focus:border-[#ff3399] focus:outline-none"
|
class="h-4 w-4 border border-green-400 bg-[#000f00] text-green-500 focus:ring-pink-400"
|
||||||
/>
|
/>
|
||||||
|
<label for="metadata" class="text-cyan-300"
|
||||||
|
>Set filename (<span class="text-red-500">slow</span>)</label
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Download Button -->
|
||||||
<a
|
<a
|
||||||
id="btn-download"
|
id="btn-download"
|
||||||
{href}
|
{href}
|
||||||
rel="external"
|
|
||||||
onclick={onClick}
|
onclick={onClick}
|
||||||
class="{disabled
|
class="{disabled
|
||||||
? 'disabled'
|
? 'pointer-events-none opacity-50'
|
||||||
: ''} block w-full rounded-lg border-4 border-[#ff3399] bg-[#ff007f] px-4 py-3 text-center text-4xl text-black transition hover:bg-[#ff3399] active:border-yellow-500"
|
: ''} block w-full rounded-md border border-pink-400 bg-pink-600 px-4 py-3 text-center text-base font-bold text-black transition hover:bg-pink-500 active:border-yellow-400"
|
||||||
>
|
>
|
||||||
DOWNLOAD
|
DOWNLOAD
|
||||||
</a>
|
</a>
|
||||||
|
@ -196,71 +189,24 @@
|
||||||
|
|
||||||
<!-- Modal -->
|
<!-- Modal -->
|
||||||
{#if showModal}
|
{#if showModal}
|
||||||
<div class="bg-opacity-80 fixed inset-0 z-50 flex items-center justify-center bg-black">
|
<div class="fixed inset-0 z-50 flex items-center justify-center bg-black/90 text-green-300">
|
||||||
<div
|
<div class="w-[90%] max-w-md rounded-lg border border-green-400 bg-[#001a00] p-5 text-center">
|
||||||
class="w-4/5 max-w-lg rounded-lg border-4 border-[#00ff7f] bg-[#002b00] p-6 text-center text-[#00ff7f]"
|
<h2 class="mb-3 text-base font-semibold">🐙 Scaricatore v{PUBLIC_VERSION} 🐙</h2>
|
||||||
>
|
|
||||||
<h2 class="mb-4 text-lg">🐙 Scaricatore v{PUBLIC_VERSION} 🐙</h2>
|
|
||||||
<p>
|
<p>
|
||||||
This app allows you to download Spotify playlists and YouTube videos directly. Choose your
|
Download Spotify playlists and YouTube videos with ease. Choose your source, paste a link,
|
||||||
source, paste the link, and select a format to start downloading!
|
select format, go!
|
||||||
</p>
|
</p>
|
||||||
<span class="mt-10 block">
|
<p class="mt-3">
|
||||||
<a class="text-[#00e5ff] underline" href="https://git.pweapon.org/odo/dl.emersa.it"
|
<a class="text-cyan-400 underline" href="https://git.pweapon.org/odo/dl.emersa.it"
|
||||||
>Click here for the source code</a
|
>Source Code</a
|
||||||
>
|
>
|
||||||
</span>
|
</p>
|
||||||
<button
|
<button
|
||||||
onclick={toggleModal}
|
onclick={toggleModal}
|
||||||
class="mt-6 rounded-lg border-4 border-[#ff3399] bg-[#ff007f] px-4 py-2 text-black hover:bg-[#ff3399]"
|
class="mt-6 rounded-md border border-pink-400 bg-pink-600 px-4 py-2 text-black hover:bg-pink-500"
|
||||||
>
|
>
|
||||||
Close
|
Close
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<style>
|
|
||||||
* {
|
|
||||||
font-family: 'Press Start 2P', cursive;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-height: 1000px) {
|
|
||||||
* {
|
|
||||||
font-size: 10px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@media (min-width: 1024px) {
|
|
||||||
* {
|
|
||||||
font-size: 12px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#loader {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
#loader.downloading {
|
|
||||||
display: grid;
|
|
||||||
justify-items: center;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
input[type='url'],
|
|
||||||
select {
|
|
||||||
font-family: inherit;
|
|
||||||
}
|
|
||||||
|
|
||||||
#title {
|
|
||||||
font-size: 18px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#btn-download {
|
|
||||||
font-size: 26px;
|
|
||||||
transition: opacity 0.3s ease;
|
|
||||||
}
|
|
||||||
a.disabled {
|
|
||||||
pointer-events: none;
|
|
||||||
cursor: default;
|
|
||||||
opacity: 0.5;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
|
@ -38,21 +38,21 @@ const validateRequest = (url: URL) => {
|
||||||
};
|
};
|
||||||
export const GET: RequestHandler = async ({ url }) => {
|
export const GET: RequestHandler = async ({ url }) => {
|
||||||
const { format, source, metadata, link } = validateRequest(url);
|
const { format, source, metadata, link } = validateRequest(url);
|
||||||
let filename = `you-clicked-no-metadata-so-i-cant-put-a-correct-name.${format}`;
|
let filename = '';
|
||||||
|
let contentLength = 0;
|
||||||
|
|
||||||
if (!!metadata) {
|
try {
|
||||||
try {
|
logger.debug(`Fetching video data to set filename`);
|
||||||
logger.debug(`Fetching video data to set filename`);
|
// Fetch metadata for filename
|
||||||
// Fetch metadata for filename
|
const ytMetadata = await getYouTubeMetadata(link);
|
||||||
const ytMetadata = await getYouTubeMetadata(link);
|
const { title, uploader, filesize_approx } = ytMetadata;
|
||||||
const { title, uploader } = ytMetadata;
|
contentLength = filesize_approx;
|
||||||
const safeTitle = `${uploader} - ${title}`;
|
const safeTitle = `${uploader} - ${title}`;
|
||||||
filename = `${safeTitle}.${format}`;
|
filename = `${safeTitle}.${format}`;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error(err);
|
logger.error(err);
|
||||||
logger.error('Error fetching metadata:');
|
logger.error('Error fetching metadata:');
|
||||||
throw error(500, 'Failed to fetch video metadata');
|
throw error(500, 'Failed to fetch video metadata');
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -60,8 +60,8 @@ export const GET: RequestHandler = async ({ url }) => {
|
||||||
return new Response(streamYouTube(link, format), {
|
return new Response(streamYouTube(link, format), {
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': `${mimeTypeMap.get(format)}`,
|
'Content-Type': `${mimeTypeMap.get(format)}`,
|
||||||
'Content-Disposition': `attachment; filename="${filename}"`,
|
'Content-Length': contentLength,
|
||||||
'Set-Cookie': 'downloading=0'
|
'Content-Disposition': `attachment; filename="${filename}"`
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue