150MB default file

This commit is contained in:
0d0 2025-04-22 20:49:43 +02:00
parent f72ea7589c
commit 46c5bc6d7b
2 changed files with 5 additions and 5 deletions

View file

@ -50,7 +50,7 @@
if (value) { if (value) {
chunks.push(value); chunks.push(value);
receivedLength += value.length; receivedLength += value.length;
progress = Math.round((receivedLength / contentLength) * 100); progress = Math.round((receivedLength / 150000) * 100);
} }
} }
@ -72,6 +72,8 @@
downloading = false; downloading = false;
link = ''; link = '';
progress = 0;
filename = '';
}; };
const createAnchor = () => { const createAnchor = () => {

View file

@ -39,7 +39,6 @@ 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 = ''; let filename = '';
let contentLength = 0;
logger.debug(`Requested: ${link}`); logger.debug(`Requested: ${link}`);
@ -47,8 +46,7 @@ export const GET: RequestHandler = async ({ url }) => {
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) {
@ -62,7 +60,7 @@ 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-Length': contentLength,
'Content-Disposition': `attachment; filename="${filename}"` 'Content-Disposition': `attachment; filename="${filename}"`
} }
}); });