returnmessage.channel.send('Can\'t download video longer than 5 minutes');
}
}
console.log('Download started');
console.log('filename: '+info._filename);
console.log('size: '+info.size);
if(info.size>=8000000){
needCompress=true;
}
});
video.on('end',function(){
if(!needCompress){
message.delete();
returnmessage.channel.send(`Downloaded by ${message.author.username}`,{files:['./SPOILER_video.mp4']})
.catch(()=>message.channel.send('File too big'));
}
constoptions={
input:'SPOILER_video.mp4',
output:'SPOILER_videoReady.mp4',
preset:'General/Gmail Small 10 Minutes 288p30'
};
//Compress vid if bigger than 8MB
lethandbrake=hbjs.spawn(options);
handbrake.on('start',function(){
message.channel.send('Video bigger than 8MB compressing now <a:loadingmin:527579785212329984> (This can take a long time!)\nWant it to go faster? Donate to the dev with the donate command, so i can get a better server and do it faster!').then(msg=>{
handbrake.on('end',function(){
msg.delete();
});
});
});
handbrake.on('error',err=>{
message.channel.send('An error has occured while compressing the video');
console.error(err);
});
handbrake.on('progress',progress=>{
console.log(
'Percent complete: %s, ETA: %s',
progress.percentComplete,
progress.eta
);
});
handbrake.on('end',function(){
message.delete();
message.channel.send(`Downloaded by ${message.author.username}`,{files:['./SPOILER_videoReady.mp4']})
.catch(()=>message.channel.send('File too big'));
});
});
}else{
message.channel.send('You need to input a valid link');