wait for segment request timeout and auto download retry

This commit is contained in:
Felipe Andrada 2020-11-30 01:36:50 -03:00
commit 6f7894a242

View file

@ -107,7 +107,7 @@ function combineSegments(type, i, segmentsUrl, output, filename, downloadingFlag
`Downloading ${type} segment ${i}/${segmentsUrl.length} of ${filename}` `Downloading ${type} segment ${i}/${segmentsUrl.length} of ${filename}`
); );
https let req = https
.get(segmentsUrl[i], res => { .get(segmentsUrl[i], res => {
res.on("data", d => output.write(d)); res.on("data", d => output.write(d));
@ -118,6 +118,10 @@ function combineSegments(type, i, segmentsUrl, output, filename, downloadingFlag
.on("error", e => { .on("error", e => {
cb(e); cb(e);
}); });
req.setTimeout(7000, function () {
console.log("Timeout. Retrying");
combineSegments(type, i, segmentsUrl, output, filename, downloadingFlag, cb)
})
} }
function getJson(url, cb) { function getJson(url, cb) {