mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-02-01 00:18:14 +01:00
Merge pull request #300 from ISO-B/ffprobe_using_json
Fixes reading multiline data from file tags
This commit is contained in:
commit
0a4ecc2125
@ -41,6 +41,7 @@
|
|||||||
"jsonwebtoken": "^8.5.1",
|
"jsonwebtoken": "^8.5.1",
|
||||||
"libgen": "^2.1.0",
|
"libgen": "^2.1.0",
|
||||||
"njodb": "^0.4.27",
|
"njodb": "^0.4.27",
|
||||||
|
"node-ffprobe": "^3.0.0",
|
||||||
"node-cron": "^3.0.0",
|
"node-cron": "^3.0.0",
|
||||||
"node-stream-zip": "^1.15.0",
|
"node-stream-zip": "^1.15.0",
|
||||||
"podcast": "^1.3.0",
|
"podcast": "^1.3.0",
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
var Ffmpeg = require('fluent-ffmpeg')
|
const ffprobe = require('node-ffprobe')
|
||||||
const Path = require('path')
|
const Path = require('path')
|
||||||
|
|
||||||
const AudioProbeData = require('../scanner/AudioProbeData')
|
const AudioProbeData = require('../scanner/AudioProbeData')
|
||||||
@ -128,7 +128,7 @@ function parseMediaStreamInfo(stream, all_streams, total_bit_rate) {
|
|||||||
function parseChapters(chapters) {
|
function parseChapters(chapters) {
|
||||||
if (!chapters) return []
|
if (!chapters) return []
|
||||||
return chapters.map(chap => {
|
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
|
var timebase = chap.time_base && chap.time_base.includes('/') ? Number(chap.time_base.split('/')[1]) : 1
|
||||||
return {
|
return {
|
||||||
id: chap.id,
|
id: chap.id,
|
||||||
@ -253,27 +253,23 @@ function parseProbeData(data, verbose = false) {
|
|||||||
|
|
||||||
// Updated probe returns AudioProbeData object
|
// Updated probe returns AudioProbeData object
|
||||||
function probe(filepath, verbose = false) {
|
function probe(filepath, verbose = false) {
|
||||||
return new Promise((resolve) => {
|
return ffprobe(filepath)
|
||||||
Ffmpeg.ffprobe(filepath, ['-show_chapters'], (err, raw) => {
|
.then(raw => {
|
||||||
if (err) {
|
|
||||||
console.error(err)
|
|
||||||
var errorMsg = err ? err.message : null
|
|
||||||
resolve({
|
|
||||||
error: errorMsg || 'Probe Error'
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
var rawProbeData = parseProbeData(raw, verbose)
|
var rawProbeData = parseProbeData(raw, verbose)
|
||||||
if (!rawProbeData || !rawProbeData.audio_stream) {
|
if (!rawProbeData || !rawProbeData.audio_stream) {
|
||||||
resolve({
|
return {
|
||||||
error: rawProbeData ? 'Invalid audio file: no audio streams found' : 'Probe Failed'
|
error: rawProbeData ? 'Invalid audio file: no audio streams found' : 'Probe Failed'
|
||||||
})
|
}
|
||||||
} else {
|
} else {
|
||||||
var probeData = new AudioProbeData()
|
var probeData = new AudioProbeData()
|
||||||
probeData.setData(rawProbeData)
|
probeData.setData(rawProbeData)
|
||||||
resolve(probeData)
|
return probeData
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
return {
|
||||||
|
error: err
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
module.exports.probe = probe
|
module.exports.probe = probe
|
Loading…
Reference in New Issue
Block a user