Show % when compressing
This commit is contained in:
parent
13783856da
commit
57c5d5a0a5
1 changed files with 21 additions and 5 deletions
|
@ -96,17 +96,33 @@ class DownloadCommand extends Command {
|
||||||
compressmsg.delete();
|
compressmsg.delete();
|
||||||
return message.channel.send('An error has occured while compressing the video');
|
return message.channel.send('An error has occured while compressing the video');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
let percentComplete;
|
||||||
|
let eta;
|
||||||
|
|
||||||
handbrake.on('progress', progress => {
|
handbrake.on('progress', progress => {
|
||||||
console.log(
|
percentComplete = progress.percentComplete;
|
||||||
'Percent complete: %s, ETA: %s',
|
eta = progress.eta;
|
||||||
progress.percentComplete,
|
console.log(`Percent complete: ${progress.percentComplete}, ETA: ${progress.eta}`);
|
||||||
progress.eta
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Every 5 seconds update the compress message with the %
|
||||||
|
setInterval(() => {
|
||||||
|
compressmsg.edit(`Compression status: Percent complete: ${percentComplete}, ETA: ${eta}\nWant it to go faster? Donate to the dev with the donate command, so i can get a better server and do it faster!`);
|
||||||
|
}, 5000);
|
||||||
|
|
||||||
handbrake.on('end', async function () {
|
handbrake.on('end', async function () {
|
||||||
|
file = fs.statSync(`${os.tmpdir()}/${fileName}compressed.mp4`);
|
||||||
|
fileSize = file.size / 1000000.0;
|
||||||
|
|
||||||
message.delete();
|
message.delete();
|
||||||
compressmsg.delete();
|
compressmsg.delete();
|
||||||
|
|
||||||
|
if (fileSize > 8) {
|
||||||
|
return message.channel.send('File too big!');
|
||||||
|
}
|
||||||
|
|
||||||
return message.channel.send({embed: Embed, files: [`${os.tmpdir()}/${fileName}compressed.mp4`]})
|
return message.channel.send({embed: Embed, files: [`${os.tmpdir()}/${fileName}compressed.mp4`]})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
|
Loading…
Reference in a new issue