mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-02-28 16:11:28 +01:00
Fixes m4b chapters only taken from first file.
This commit is contained in:
parent
5724887785
commit
80ef8ee890
@ -421,9 +421,26 @@ class Book {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// IF first audio file has embedded chapters then use embedded chapters
|
// IF first audio file has embedded chapters then use embedded chapters
|
||||||
if (includedAudioFiles[0].chapters && includedAudioFiles[0].chapters.length) {
|
if (includedAudioFiles[0].chapters?.length) {
|
||||||
Logger.debug(`[Book] setChapters: Using embedded chapters in audio file ${includedAudioFiles[0].metadata.path}`)
|
Logger.debug(`[Book] setChapters: Using embedded chapters in audio file ${includedAudioFiles[0]?.metadata?.path}`)
|
||||||
this.chapters = includedAudioFiles[0].chapters.map(c => ({ ...c }))
|
this.chapters = []
|
||||||
|
let currChapterId = 0
|
||||||
|
let currStartTime = 0
|
||||||
|
|
||||||
|
includedAudioFiles.forEach((file) => {
|
||||||
|
if (file.duration) {
|
||||||
|
let chapters = file.chapters?.map((c) => ({
|
||||||
|
...c,
|
||||||
|
id: c.id + currChapterId,
|
||||||
|
start: c.start + currStartTime,
|
||||||
|
end: c.end + currStartTime,
|
||||||
|
}))
|
||||||
|
this.chapters = this.chapters.concat(chapters)
|
||||||
|
|
||||||
|
currChapterId += file.chapters?.length ?? 0
|
||||||
|
currStartTime += file.duration
|
||||||
|
}
|
||||||
|
})
|
||||||
} else if (includedAudioFiles.length > 1) {
|
} else if (includedAudioFiles.length > 1) {
|
||||||
// Build chapters from audio files
|
// Build chapters from audio files
|
||||||
this.chapters = []
|
this.chapters = []
|
||||||
@ -461,4 +478,4 @@ class Book {
|
|||||||
return this.metadata.authorName
|
return this.metadata.authorName
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
module.exports = Book
|
module.exports = Book
|
||||||
|
Loading…
Reference in New Issue
Block a user