From db38f8c4d68d387999b5621a0cf61c7f8bad6763 Mon Sep 17 00:00:00 2001 From: Violet Date: Wed, 25 Oct 2023 18:07:54 -0500 Subject: [PATCH] NO MORE FILENAME OPTION! --- index.js | 12 ++++++------ static/index.html | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index a4591ed..c10d134 100644 --- a/index.js +++ b/index.js @@ -38,7 +38,6 @@ process.on('uncaughtException', (err, origin) => { app.use(bodyParser.urlencoded({ extended: false })) app.get("/getLink", async (req, res) => { - const filename = req.query.filename const url = req.query.url const format = req.query.format const quality = req.query.quality @@ -50,6 +49,11 @@ app.get("/getLink", async (req, res) => { res.write(`

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

`) return } + + var vidinfo = await ytdl.getBasicInfo(url) + + const filename = vidinfo.videoDetails.title + if (["mp4", "webm"].includes(format)) { var ytvid = ytdl(url, { 'quality': quality, 'format': format }) var debounce = false @@ -80,8 +84,6 @@ app.get("/getLink", async (req, res) => { // String(Math.floor(Math.random() * 100000)) + var ytpath = path.join(__dirname, 'cached/' + ytdl.getVideoID(url) + '.mp4') - var vidinfo = await ytdl.getBasicInfo(url) - if (redir != "redirect") { res.write(`

Starting download...

`) } @@ -112,11 +114,9 @@ app.get("/getLink", async (req, res) => { } var proc = new ffmpeg(ytpath) // res.write(`

Converting... (May take a while, doesn't support progress updates yet)

`) - var endpath = ('cached/' + ytdl.getVideoID(url) + String(Math.floor(Math.random() * 100000)) + "Converted." + format) + var endpath = ('cached/' + ytdl.getVideoID(url) + String(Math.floor(Math.random() * 10000000)) + "Converted." + format) if (redir != "redirect") { res.write(`

Starting Video Conversion... Conversion may be slow depending on instance.

`) - } else { - console.log(redir) } proc.then(function (video) { video diff --git a/static/index.html b/static/index.html index fa98a5d..57d0b48 100644 --- a/static/index.html +++ b/static/index.html @@ -29,10 +29,10 @@ -
+

Format: