From 947fbe824b60af01177967be33a8d98fddef571d Mon Sep 17 00:00:00 2001 From: przemyslawpluta Date: Sat, 9 Jan 2016 14:30:13 +0000 Subject: retry if network connection issues --- lib/videos.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/videos.js') 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); } } -- cgit v1.2.3