diff --git a/vimeomaster.js b/vimeomaster.js index 3c299cf..4ad704b 100644 --- a/vimeomaster.js +++ b/vimeomaster.js @@ -107,7 +107,7 @@ function combineSegments(type, i, segmentsUrl, output, filename, downloadingFlag `Downloading ${type} segment ${i}/${segmentsUrl.length} of ${filename}` ); - https + let req = https .get(segmentsUrl[i], res => { res.on("data", d => output.write(d)); @@ -118,12 +118,17 @@ function combineSegments(type, i, segmentsUrl, output, filename, downloadingFlag .on("error", e => { cb(e); }); + + req.setTimeout(7000, function () { + log("⚠️", 'Timeout. Retrying'); + combineSegments(type, i, segmentsUrl, output, filename, downloadingFlag, cb); + }); } function getJson(url, cb) { let data = ""; - let req = https + https .get(url, res => { res.on("data", d => (data += d)); @@ -132,11 +137,6 @@ function getJson(url, cb) { .on("error", e => { cb(e); }); - - req.setTimeout(7000, function () { - log("⚠️", 'Timeout. Retrying'); - combineSegments(type, i, segmentsUrl, output, filename, downloadingFlag, cb); - }); } function initJs(n = 0) {