From cd0cc69fd856bc9e8a69141f23d30a87383fa869 Mon Sep 17 00:00:00 2001 From: calzoneman Date: Sat, 23 May 2015 14:36:13 -0400 Subject: [PATCH] Gracefully handle HTTP errors in ffprobe --- lib/ffmpeg.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/ffmpeg.js b/lib/ffmpeg.js index 972af6c8..602c9cfe 100644 --- a/lib/ffmpeg.js +++ b/lib/ffmpeg.js @@ -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");