Added error message parser

This commit is contained in:
freearhey 2019-10-25 22:45:50 +03:00
parent 9f5ff544aa
commit fb6890682b
1 changed files with 17 additions and 3 deletions

View File

@ -46,9 +46,7 @@ async function test() {
ffmpeg(item.url, { timeout: config.timeout }).ffprobe((err) => {
if(err) {
const message = err.message.split('\n').find(line => {
return /^\[[\w|\s|\d|@|\]]+/i.test(line)
}).split(']')[1].trim()
const message = parseMessage(err, item.url)
stats.failures++
@ -88,3 +86,19 @@ function writeToLog(country, msg, url) {
util.appendToFile(errorLog, now.toISOString() + ' ' + line + '\n')
console.log(`${msg} '${url}'`)
}
function parseMessage(err, u) {
if(!err || !err.message) return
const msgArr = err.message.split('\n')
if(msgArr.length === 0) return
const line = msgArr.find(line => {
return line.indexOf(u) === 0
})
if(!line) return
return line.replace(`${u}: `, '')
}