From ab698f112b17fc74ea91f94cdeb94171e3de770c Mon Sep 17 00:00:00 2001 From: Violet <110205356+Violets-puragtory@users.noreply.github.com> Date: Wed, 25 Oct 2023 21:04:42 +0000 Subject: [PATCH] Fixed block and other things --- index.js | 37 +++++++++++++++++++------------------ static/style.css | 2 +- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/index.js b/index.js index a065d67..a4591ed 100644 --- a/index.js +++ b/index.js @@ -47,26 +47,33 @@ app.get("/getLink", async (req, res) => { if (!ytdl.validateURL(url)) { res.header("Content-Type", "text/html") res.write(``) - res.write(`

Invalid URL! Check the url for any errors!
${url}

`) + res.write(`

Invalid URL! Check the url for any errors!
URL: ${url}

`) return } if (["mp4", "webm"].includes(format)) { var ytvid = ytdl(url, { 'quality': quality, 'format': format }) var debounce = false - ytvid.on("progress", (chunk, cd, td) => { - if (!debounce) { - res.setHeader('Content-Disposition', `attachment; filename="${filename}.${format}";`); - res.setHeader("Content-Length", td) - ytvid.pipe(res) - // console.log(td) - debounce = true - } - }) + ytvid.on("progress", (chunk, cd, td) => { + if (!debounce) { + res.setHeader('Content-Disposition', `attachment; filename="${filename}.${format}";`); + res.setHeader("Content-Length", td) + ytvid.pipe(res) + // console.log(td) + debounce = true + } + }) } else { if (redir != "redirect") { res.setHeader("Content-Type", "text/html"); res.write(``) + res.write(` + + `) } @@ -148,16 +155,11 @@ app.get("/getLink", async (req, res) => { }) var count = 0 - var integer = 1 - var lastc = 0 - var percent = 0 + async function update() { if (fs.existsSync(endpath)) { var ffile = await fs.readFileSync(endpath) var yt = await fs.readFileSync(ytpath) - percent = (Math.round(ffile.length / yt.length * (100 / integer))) * integer - // console.log(ffile.length) - // if (ffile.length != lastc) { res.write(`

Converting... (${formatBytes(ffile.length)})

`) res.write(` `) - lastc = percent count += 1 // } } - if (percent < 100 && redir != "redirect") { + if ( redir != "redirect") { setTimeout(() => { update() }, 2000); diff --git a/static/style.css b/static/style.css index bc779ea..3741f30 100644 --- a/static/style.css +++ b/static/style.css @@ -24,7 +24,7 @@ input { p { margin: 5px; - display: inline-block + display: inline-block; } body,