From faa6e954b081c94ef5fdbed2fc8d5476db39a326 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Bersier?= Date: Tue, 26 Mar 2019 01:19:43 +0100 Subject: [PATCH] Alternate download for thing like twitter --- commands/utility/download.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/commands/utility/download.js b/commands/utility/download.js index 3762431d..567483f1 100644 --- a/commands/utility/download.js +++ b/commands/utility/download.js @@ -14,6 +14,10 @@ class DownloadCommand extends Command { id: 'link', type: 'string', default: 'https://www.youtube.com/watch?v=6n3pFFPSlW4' + }, + { + id: 'alt', + type: 'bool', } ], clientPermissions: ['ATTACH_FILES'], @@ -30,6 +34,21 @@ class DownloadCommand extends Command { let needCompress = false; if (link.includes('http') || link.includes('www')) { + if (args.alt) { + console.log('alt download!') + fs.unlink('./video.mp4', (err) => { + if (err); + }); + return youtubedl.exec(args.link, ['-o', `./video.mp4`], {}, function(err, output) { + if (err) throw err; + console.log(output.join('\n')); + message.delete(); + message.channel.send(`Downloaded by ${message.author.username}`, { files: ['./video.mp4'] }) + .catch(() => message.channel.send('File too big')); + }); + } + + let video = youtubedl(link, [`--username=${fbuser}`, `--password=${fbpasswd}`]); video.pipe(fs.createWriteStream('./video.mp4')); video.on('error', function error(err) {