This commit is contained in:
Flummi 2016-08-24 07:49:17 +00:00
parent c7a48d4fae
commit 91a2edcce7

View File

@ -18,15 +18,23 @@ module.exports = (bot, trigger, lib) => {
lib.checkRepost(entry, (cbcr) => {
if(cbcr) {
var dat = fs.createWriteStream('./b/'+tmpdest+'.webm');
ytdl(entry, { filter: (format) => { return format.container === 'webm'; } })
.on('response', (res) => {
if(res.headers['content-length'] > lib.cfg.maxFileSize) {
res.destroy();
dl = false;
e.reply('f0ck! your file is too big (~'+lib.formatSize(res.headers['content-length'])+'), max '+lib.formatSize(lib.cfg.maxFileSize)+' allowed');
}
})
.pipe( dat );
try {
ytdl(entry, { filter: (format) => { return format.container === 'webm'; } })
.on('response', (res) => {
if(res.headers['content-length'] > lib.cfg.maxFileSize) {
res.destroy();
dl = false;
e.reply('f0ck! your file is too big (~'+lib.formatSize(res.headers['content-length'])+'), max '+lib.formatSize(lib.cfg.maxFileSize)+' allowed');
}
})
.pipe( dat );
}
catch(ex) {
dat.close();
fs.unlink('./b/'+tmpdest+'.webm');
e.reply("noep");
dl = false;
}
dat.on('finish', () => {
if(dl) {
dat.close();