diff options
Diffstat (limited to 'lib/videos.js')
-rw-r--r-- | lib/videos.js | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/lib/videos.js b/lib/videos.js index c2b323c..2431a53 100644 --- a/lib/videos.js +++ b/lib/videos.js @@ -14,7 +14,7 @@ var path = require('path'), request = require('request'), progress = require('request-progress'), colors = require('colors'), - unzip = require('unzip'), + extract = require('extract-zip'), rimraf = require('rimraf'), mv = require('mv'), _ = require('lodash'); @@ -102,14 +102,11 @@ var handleList = function handleList(list, tags) { return nextItem(currentList); } - unzipFile = fs.createReadStream(downloadPath + name).pipe(unzip.Extract({ path: downloadPath + path.basename(name, extname) })); - - unzipFile.on('error', function error() { - console.log('i'.red + ' Unable to unzip ' + name.red + ' try manually.'); - rimraf(downloadPath + name.replace('.zip', ''), function rf() { nextItem(currentList); }); - }); - - unzipFile.on('close', function close() { + unzipFile = extract(downloadPath + name, {dir: downloadPath + path.basename(name, extname)}, function out(err) { + if (err) { + console.log('i'.red + ' Unable to unzip ' + name.red + ' try manually.'); + return rimraf(downloadPath + name.replace('.zip', ''), function rf() { nextItem(currentList); }); + } console.log('i'.green + ' Done.' + left); cleanup(downloadPath + name, currentList); }); |