From e7edf407592a02860f049f3311124087efddc96d Mon Sep 17 00:00:00 2001 From: loicbersier Date: Thu, 16 Jan 2020 18:13:27 +0100 Subject: [PATCH] Allow hidden download for alt download --- app/Controllers/Http/DownloadController.js | 17 ++++++++++++----- resources/views/index.edge | 3 --- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/app/Controllers/Http/DownloadController.js b/app/Controllers/Http/DownloadController.js index 3c44915..fa88f1c 100644 --- a/app/Controllers/Http/DownloadController.js +++ b/app/Controllers/Http/DownloadController.js @@ -89,13 +89,20 @@ class DownloadController { // If alt download ( Quality settings and file format option doesn't work here ) if (data.alt) { - if (fs.existsSync('./public/uploads/alt.mp4')) { - fs.unlink('./public/uploads/alt.mp4', (err) => { + let altFolder; + if (data.feed == 'on') { + altFolder = './public/uploads/hidden/alt.mp4'; + } else { + altFolder = './public/uploads/alt.mp4' + } + + if (fs.existsSync(altFolder)) { + fs.unlink(altFolder, (err) => { if (err); }); } - return youtubedl.exec(data.url, ['--format=mp4', '-o', `public/uploads/alt.mp4`], {}, function(err, output) { + return youtubedl.exec(data.url, ['--format=mp4', '-o', altFolder], {}, function(err, output) { if (err) { return view.render(page, { title: title, @@ -107,7 +114,7 @@ class DownloadController { }); } - return response.attachment('./public/uploads/alt.mp4'); + return response.attachment(altFolder); }); } else { // Download as mp4 if possible @@ -129,7 +136,7 @@ class DownloadController { video.on('info', function(info) { // Set file name ext = info.ext; - let title = info.title.slice(0,80); + let title = info.title.slice(0,50); DLFile = `${title.replace(/\s/g, '_')}.${ext}`; // If no title use the ID diff --git a/resources/views/index.edge b/resources/views/index.edge index e64e615..2d6eb59 100644 --- a/resources/views/index.edge +++ b/resources/views/index.edge @@ -214,11 +214,8 @@ document.getElementById('flac').checked = false; document.getElementById('mp4').checked = true; document.getElementById('high').checked = true; - document.getElementById('feed').checked = false; - document.getElementById('feed').disabled = true; } else { document.getElementById('small').disabled = false; - document.getElementById('feed').disabled = false; document.getElementById('mp3').disabled = false; document.getElementById('flac').disabled = false; }