Alternate download for thing like twitter

This commit is contained in:
Loïc Bersier 2019-03-26 01:19:43 +01:00
parent fc36b6dfce
commit faa6e954b0

View file

@ -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) {