Merge pull request #300 from ISO-B/ffprobe_using_json

Fixes reading multiline data from file tags
This commit is contained in:
advplyr 2022-01-07 16:51:34 -06:00 committed by GitHub
commit 0a4ecc2125
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 22 deletions

View File

@ -41,6 +41,7 @@
"jsonwebtoken": "^8.5.1",
"libgen": "^2.1.0",
"njodb": "^0.4.27",
"node-ffprobe": "^3.0.0",
"node-cron": "^3.0.0",
"node-stream-zip": "^1.15.0",
"podcast": "^1.3.0",

View File

@ -1,4 +1,4 @@
var Ffmpeg = require('fluent-ffmpeg')
const ffprobe = require('node-ffprobe')
const Path = require('path')
const AudioProbeData = require('../scanner/AudioProbeData')
@ -128,7 +128,7 @@ function parseMediaStreamInfo(stream, all_streams, total_bit_rate) {
function parseChapters(chapters) {
if (!chapters) return []
return chapters.map(chap => {
var title = chap['TAG:title'] || chap.title || ''
var title = chap['TAG:title'] || chap.title || chap.tags.title || ''
var timebase = chap.time_base && chap.time_base.includes('/') ? Number(chap.time_base.split('/')[1]) : 1
return {
id: chap.id,
@ -253,27 +253,23 @@ function parseProbeData(data, verbose = false) {
// Updated probe returns AudioProbeData object
function probe(filepath, verbose = false) {
return new Promise((resolve) => {
Ffmpeg.ffprobe(filepath, ['-show_chapters'], (err, raw) => {
if (err) {
console.error(err)
var errorMsg = err ? err.message : null
resolve({
error: errorMsg || 'Probe Error'
})
} else {
var rawProbeData = parseProbeData(raw, verbose)
if (!rawProbeData || !rawProbeData.audio_stream) {
resolve({
error: rawProbeData ? 'Invalid audio file: no audio streams found' : 'Probe Failed'
})
} else {
var probeData = new AudioProbeData()
probeData.setData(rawProbeData)
resolve(probeData)
return ffprobe(filepath)
.then(raw => {
var rawProbeData = parseProbeData(raw, verbose)
if (!rawProbeData || !rawProbeData.audio_stream) {
return {
error: rawProbeData ? 'Invalid audio file: no audio streams found' : 'Probe Failed'
}
} else {
var probeData = new AudioProbeData()
probeData.setData(rawProbeData)
return probeData
}
})
.catch((err) => {
return {
error: err
}
})
})
}
module.exports.probe = probe