diff options
author | przemyslawpluta <przemekpluta@hotmail.com> | 2016-01-09 14:30:13 +0000 |
---|---|---|
committer | przemyslawpluta <przemekpluta@hotmail.com> | 2016-01-09 14:30:13 +0000 |
commit | 947fbe824b60af01177967be33a8d98fddef571d (patch) | |
tree | 332f64744bf33d49df813b438146810dc56cdc9b | |
parent | 6f85d4d542f7d6d9f6e807faa89ca26cc2124a5d (diff) | |
download | mongo-edu-947fbe824b60af01177967be33a8d98fddef571d.zip |
retry if network connection issues
-rw-r--r-- | lib/videos.js | 5 | ||||
-rw-r--r-- | package.json | 4 |
2 files changed, 5 insertions, 4 deletions
diff --git a/lib/videos.js b/lib/videos.js index 7c2e56d..1ba0ce7 100644 --- a/lib/videos.js +++ b/lib/videos.js @@ -21,7 +21,7 @@ var path = require('path'), moment = require('moment'); var isDebug = /[debug]/, downloadPath = '', proxy = '', downloadList = [], hash = {}, - co = false, ncc = false, handout = false, cc = false, uz = false, hq = false, verbose = false, retry = 0, maxRetry; + co = false, ncc = false, handout = false, cc = false, uz = false, hq = false, verbose = false, retry = 10, maxRetry; function setOptions(argv) { @@ -197,13 +197,14 @@ var handleList = function handleList(list, tags) { }); dl.on('error', function error(err) { + if (err.message.indexOf('requested format not available') !== -1) { _.pull(opt, '--format=22'); opt.push('--format=18'); return getVideos(item, true); } - if (err.message.match(/Command failed: python|ENETDOWN|ENOTFOUND|EAI_AGAIN/) && retry !== 0) { + if (err.message.match(/Command failed: python|ENETDOWN|ENOTFOUND|EAI_AGAIN/) && retry > 0) { if (!maxRetry) { maxRetry = moment().add(retry, 'seconds'); } if (maxRetry && maxRetry.diff(moment()) > 0) { return delay(item); } } diff --git a/package.json b/package.json index 9788430..dc5ca39 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "mongo-edu", "preferGlobal": true, - "version": "0.2.40", + "version": "0.2.50", "author": "Przemyslaw Pluta <przemyslawplutadev@gmail.com> (http://przemyslawpluta.com)", "description": "Select and download videos and handouts from university.mongodb.com courses", "main": "./mongo-edu", @@ -40,7 +40,7 @@ "inquirer": "~0.11.1", "lodash": "~3.10.1", "mkdirp": "~0.5.1", - "moment": "^2.11.0", + "moment": "~2.11.1", "mv": "~2.1.1", "path-extra": "~3.0.0", "pretty-error": "~2.0.0", |