From f1d7b8453fc26cca52412b2ea7173c762832b5b0 Mon Sep 17 00:00:00 2001 From: supositware Date: Sun, 13 Jun 2021 16:02:46 +0200 Subject: [PATCH] advanced settings for format --- routes/index.js | 14 +++++++++----- views/index.ejs | 14 ++++++-------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/routes/index.js b/routes/index.js index a693901..ee29520 100644 --- a/routes/index.js +++ b/routes/index.js @@ -88,7 +88,6 @@ router.get('/status/:uuid', function (req, res ,next) { router.get('/format', function (req, res ,next) { let url; - let i = 0; try { url = new URL(req.query.url); } catch (e) { @@ -100,17 +99,22 @@ router.get('/format', function (req, res ,next) { youtubedl.exec(url.href, ['--dump-json'], {}, function(err, output) { if (err) throw err let json = JSON.parse(output); + console.log(req.query.advanced); json.formats.forEach(format => { - if (format.vcodec === 'none' || format.acodec === 'none') + if (req.query.advanced === 'false' && (format.vcodec === 'none' || format.acodec === 'none')) return; - i++; - formats.push({ext: format.ext, id: format.format_id, note: `${format.width}x${format.height}`}); + let note = `${format.width}x${format.height}`; + + if (req.query.advanced === 'true') { + note = format.format + } + + formats.push({ext: format.ext, id: format.format_id, note: note}); }); return res.send(formats); }); - return; }); router.post('/', async function(req, res, next) { diff --git a/views/index.ejs b/views/index.ejs index 26e1409..9751c45 100644 --- a/views/index.ejs +++ b/views/index.ejs @@ -65,16 +65,14 @@ Come take a look here https://git.namejeff.xyz/Supositware/jeff-downloader for a - - -
-
-
-
+
- +
@@ -251,7 +249,7 @@ Come take a look here https://git.namejeff.xyz/Supositware/jeff-downloader for a console.log(encodeURI(url.href)); let xhttp = new XMLHttpRequest(); - xhttp.open("get", `/format?url=${url.href}`, true); + xhttp.open("get", `/format?url=${url.href}&advanced=${document.getElementById("advanced").checked}`, true); xhttp.send(); xhttp.addEventListener("load", function(event) { console.log(event.target.responseText);