diff options
-rw-r--r-- | lib/videos.js | 15 | ||||
-rw-r--r-- | package.json | 4 |
2 files changed, 8 insertions, 11 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); }); diff --git a/package.json b/package.json index cb90e85..307e6af 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "mongo-edu", "preferGlobal": true, - "version": "0.2.24", + "version": "0.2.25", "author": "Przemyslaw Pluta <przemyslawplutadev@gmail.com> (http://przemyslawpluta.com)", "description": "Select and download videos and handouts from university.mongodb.com courses", "main": "./mongo-edu", @@ -33,6 +33,7 @@ "cheerio": "~0.19.0", "colors": "~1.1.2", "easy-table": "~1.0.0", + "extract-zip": "~1.2.0", "filesize": "~3.1.4", "glob": "~6.0.1", "inquirer": "~0.11.0", @@ -45,7 +46,6 @@ "request": "~2.67.0", "request-progress": "~0.3.1", "rimraf": "~2.4.4", - "unzip": "~0.1.11", "which": "~1.2.0", "yargs": "~3.30.0", "youtube-dl": "~1.10.5" |