it's cool that we have format
All checks were successful
Bump deps (only minor versions) / ci (push) Successful in 18s
All checks were successful
Bump deps (only minor versions) / ci (push) Successful in 18s
This commit is contained in:
parent
760812c692
commit
652208aa57
6 changed files with 69 additions and 60 deletions
|
@ -24,21 +24,21 @@
|
|||
};
|
||||
|
||||
onMount(() => {
|
||||
document.cookie = 'downloading=0'
|
||||
document.cookie = 'downloading=0';
|
||||
});
|
||||
|
||||
const readLogs = () => {
|
||||
logId = setInterval(() => {
|
||||
logs += "We're downloading <br>"
|
||||
}, 2000)
|
||||
}
|
||||
logs += "We're downloading <br>";
|
||||
}, 2000);
|
||||
};
|
||||
const onClick = () => {
|
||||
let checkIterations = 0;
|
||||
link = '';
|
||||
downloading = true;
|
||||
document.cookie = 'downloading=1'
|
||||
|
||||
readLogs()
|
||||
document.cookie = 'downloading=1';
|
||||
|
||||
readLogs();
|
||||
|
||||
const id = setInterval(() => {
|
||||
if (document.cookie.includes('downloading=0') || checkIterations > 3) {
|
||||
|
@ -72,8 +72,7 @@
|
|||
searchParams.append('link', link);
|
||||
searchParams.append('format', format);
|
||||
|
||||
if (metadata)
|
||||
searchParams.append('metadata', "1");
|
||||
if (metadata) searchParams.append('metadata', '1');
|
||||
|
||||
href = `/download?${searchParams.toString()}`;
|
||||
};
|
||||
|
@ -88,12 +87,18 @@
|
|||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<div
|
||||
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"
|
||||
>
|
||||
|
||||
<div id="loader" class={["backdrop-blur-xs bg-black/20 absolute inset-0 z-10 flex items-center justify-center", { downloading }]}>
|
||||
<div
|
||||
id="loader"
|
||||
class={[
|
||||
'absolute inset-0 z-10 flex items-center justify-center bg-black/20 backdrop-blur-xs',
|
||||
{ downloading }
|
||||
]}
|
||||
>
|
||||
<Loader />
|
||||
{@html logs}
|
||||
</div>
|
||||
|
@ -182,7 +187,9 @@
|
|||
|
||||
<!-- Metadata -->
|
||||
<div>
|
||||
<label for="metadata" class="mb-2 block text-[#00e5ff]">Set filename (<span class='text-red-700'>SLOW</span>)</label>
|
||||
<label for="metadata" class="mb-2 block text-[#00e5ff]"
|
||||
>Set filename (<span class="text-red-700">SLOW</span>)</label
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
id="metadata"
|
||||
|
@ -218,7 +225,7 @@
|
|||
source, paste the link, and select a format to start downloading!
|
||||
</p>
|
||||
<span class="mt-10 block">
|
||||
<a class="underline text-[#00e5ff]" href="https://git.pweapon.org/odo/dl.emersa.it"
|
||||
<a class="text-[#00e5ff] underline" href="https://git.pweapon.org/odo/dl.emersa.it"
|
||||
>Click here for the source code</a
|
||||
>
|
||||
</span>
|
||||
|
@ -237,10 +244,10 @@
|
|||
font-family: 'Press Start 2P', cursive;
|
||||
}
|
||||
|
||||
@media (max-height: 1000px) {
|
||||
@media (max-height: 1000px) {
|
||||
* {
|
||||
font-size: 10px;
|
||||
}
|
||||
}
|
||||
}
|
||||
@media (min-width: 1024px) {
|
||||
* {
|
||||
|
@ -248,14 +255,13 @@
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
#loader {
|
||||
display: none;
|
||||
}
|
||||
#loader.downloading {
|
||||
display: grid;
|
||||
justify-items: center;
|
||||
align-items: center;
|
||||
align-items: center;
|
||||
}
|
||||
.not-available {
|
||||
text-decoration-line: line-through;
|
||||
|
|
|
@ -30,9 +30,12 @@ const validateRequest = (url: URL) => {
|
|||
logger.debug(`Request is valid`);
|
||||
|
||||
return {
|
||||
link, format, source, metadata
|
||||
}
|
||||
}
|
||||
link,
|
||||
format,
|
||||
source,
|
||||
metadata
|
||||
};
|
||||
};
|
||||
export const GET: RequestHandler = async ({ url }) => {
|
||||
const { format, source, metadata, link } = validateRequest(url);
|
||||
let filename = `you-clicked-no-metadata-so-i-cant-put-a-correct-name.${format}`;
|
||||
|
@ -46,7 +49,7 @@ export const GET: RequestHandler = async ({ url }) => {
|
|||
const safeTitle = `${uploader} - ${title}`;
|
||||
filename = `${safeTitle}.${format}`;
|
||||
} catch (err) {
|
||||
logger.error(err)
|
||||
logger.error(err);
|
||||
logger.error('Error fetching metadata:');
|
||||
throw error(500, 'Failed to fetch video metadata');
|
||||
}
|
||||
|
@ -56,14 +59,13 @@ export const GET: RequestHandler = async ({ url }) => {
|
|||
// Stream video/audio
|
||||
return new Response(streamYouTube(link, format), {
|
||||
headers: {
|
||||
'Content-Type': "text/event-stream",
|
||||
'Content-Type': 'text/event-stream',
|
||||
'Content-Disposition': `attachment; filename="${filename}"`,
|
||||
'Set-Cookie': 'downloading=0'
|
||||
}
|
||||
});
|
||||
|
||||
} catch (err) {
|
||||
logger.error(err)
|
||||
logger.error(err);
|
||||
logger.error('Filed to stream file');
|
||||
throw error(500, 'Failed to stream file');
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue