Gracefully handle HTTP errors in ffprobe

This commit is contained in:
calzoneman 2015-05-23 14:36:13 -04:00
parent f94c8bc8f1
commit cd0cc69fd8
1 changed files with 10 additions and 3 deletions

View File

@ -151,12 +151,19 @@ exports.query = function (filename, cb) {
exports.ffprobe(filename, function (err, data) {
if (err) {
if (err.message && err.message.match(/protocol not found/i)) {
return cb("Link uses a protocol unsupported by this server's ffmpeg");
} else if (err.code && err.code === "ENOENT") {
if (err.code && err.code === "ENOENT") {
return cb("Failed to execute `ffprobe`. Set ffmpeg.ffprobe-exec to " +
"the correct name of the executable in config.yaml. If " +
"you are using Debian or Ubuntu, it is probably avprobe.");
} else if (err.message) {
if (err.message.match(/protocol not found/i))
return cb("Link uses a protocol unsupported by this server's ffmpeg");
var m = err.message.match(/(http error .*)/i);
if (m) return cb(m[1]);
Logger.errlog.log(err.stack || err);
return cb("Unable to query file data with ffmpeg");
} else {
Logger.errlog.log(err.stack || err);
return cb("Unable to query file data with ffmpeg");