mirror of https://github.com/calzoneman/sync.git
ffmpeg: follow relative redirects
This commit is contained in:
parent
efdab32aa8
commit
52e444ab64
|
@ -38,6 +38,14 @@ function initFFLog() {
|
||||||
fflog.initialized = true;
|
fflog.initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function fixRedirectIfNeeded(urldata, redirect) {
|
||||||
|
if (!/^https?:/.test(redirect)) {
|
||||||
|
redirect = urldata.protocol + "//" + urldata.host + redirect;
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect;
|
||||||
|
}
|
||||||
|
|
||||||
function testUrl(url, cb, redirCount) {
|
function testUrl(url, cb, redirCount) {
|
||||||
if (!redirCount) redirCount = 0;
|
if (!redirCount) redirCount = 0;
|
||||||
var data = urlparse.parse(url);
|
var data = urlparse.parse(url);
|
||||||
|
@ -59,7 +67,8 @@ function testUrl(url, cb, redirCount) {
|
||||||
return cb("Too many redirects. Please provide a direct link to the " +
|
return cb("Too many redirects. Please provide a direct link to the " +
|
||||||
"file");
|
"file");
|
||||||
}
|
}
|
||||||
return testUrl(res.headers["location"], cb, redirCount + 1);
|
return testUrl(fixRedirectIfNeeded(data, res.headers["location"]), cb,
|
||||||
|
redirCount + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res.statusCode !== 200) {
|
if (res.statusCode !== 200) {
|
||||||
|
|
Loading…
Reference in New Issue