mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-08-01 16:54:59 +02:00
Adding chapters and downloading m4b file
This commit is contained in:
parent
26d922d3dc
commit
315de87bfc
24 changed files with 311 additions and 69 deletions
|
@ -110,9 +110,23 @@ function parseMediaStreamInfo(stream, all_streams, total_bit_rate) {
|
|||
return info
|
||||
}
|
||||
|
||||
function parseChapters(chapters) {
|
||||
if (!chapters) return []
|
||||
return chapters.map(chap => {
|
||||
var title = chap['TAG:title'] || chap.title
|
||||
var timebase = chap.time_base && chap.time_base.includes('/') ? Number(chap.time_base.split('/')[1]) : 1
|
||||
return {
|
||||
id: chap.id,
|
||||
start: !isNaN(chap.start_time) ? chap.start_time : (chap.start / timebase),
|
||||
end: chap.end_time || (chap.end / timebase),
|
||||
title
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function parseProbeData(data) {
|
||||
try {
|
||||
var { format, streams } = data
|
||||
var { format, streams, chapters } = data
|
||||
var { format_long_name, duration, size, bit_rate } = format
|
||||
|
||||
var sizeBytes = !isNaN(size) ? Number(size) : null
|
||||
|
@ -146,6 +160,8 @@ function parseProbeData(data) {
|
|||
}
|
||||
}
|
||||
|
||||
cleanedData.chapters = parseChapters(chapters)
|
||||
|
||||
return cleanedData
|
||||
} catch (error) {
|
||||
console.error('Parse failed', error)
|
||||
|
@ -155,7 +171,7 @@ function parseProbeData(data) {
|
|||
|
||||
function probe(filepath) {
|
||||
return new Promise((resolve) => {
|
||||
Ffmpeg.ffprobe(filepath, (err, raw) => {
|
||||
Ffmpeg.ffprobe(filepath, ['-show_chapters'], (err, raw) => {
|
||||
if (err) {
|
||||
console.error(err)
|
||||
resolve(null)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue