150MB default file
This commit is contained in:
parent
f72ea7589c
commit
46c5bc6d7b
2 changed files with 5 additions and 5 deletions
|
@ -50,7 +50,7 @@
|
|||
if (value) {
|
||||
chunks.push(value);
|
||||
receivedLength += value.length;
|
||||
progress = Math.round((receivedLength / contentLength) * 100);
|
||||
progress = Math.round((receivedLength / 150000) * 100);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,6 +72,8 @@
|
|||
downloading = false;
|
||||
|
||||
link = '';
|
||||
progress = 0;
|
||||
filename = '';
|
||||
};
|
||||
|
||||
const createAnchor = () => {
|
||||
|
|
|
@ -39,7 +39,6 @@ const validateRequest = (url: URL) => {
|
|||
export const GET: RequestHandler = async ({ url }) => {
|
||||
const { format, source, metadata, link } = validateRequest(url);
|
||||
let filename = '';
|
||||
let contentLength = 0;
|
||||
|
||||
logger.debug(`Requested: ${link}`);
|
||||
|
||||
|
@ -47,8 +46,7 @@ export const GET: RequestHandler = async ({ url }) => {
|
|||
logger.debug(`Fetching video data to set filename`);
|
||||
// Fetch metadata for filename
|
||||
const ytMetadata = await getYouTubeMetadata(link);
|
||||
const { title, uploader, filesize_approx } = ytMetadata;
|
||||
contentLength = filesize_approx;
|
||||
const { title, uploader } = ytMetadata;
|
||||
const safeTitle = `${uploader} - ${title}`;
|
||||
filename = `${safeTitle}.${format}`;
|
||||
} catch (err) {
|
||||
|
@ -62,7 +60,7 @@ export const GET: RequestHandler = async ({ url }) => {
|
|||
return new Response(streamYouTube(link, format), {
|
||||
headers: {
|
||||
'Content-Type': `${mimeTypeMap.get(format)}`,
|
||||
'Content-Length': contentLength,
|
||||
|
||||
'Content-Disposition': `attachment; filename="${filename}"`
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue