mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2024-12-20 19:06:06 +01:00
Update:When merging embedded chapters from multiple files filter out ~0 duration chapters #3361
This commit is contained in:
parent
5b22e945da
commit
bb7938f66d
@ -475,16 +475,26 @@ class AudioFileScanner {
|
|||||||
|
|
||||||
audioFiles.forEach((file) => {
|
audioFiles.forEach((file) => {
|
||||||
if (file.duration) {
|
if (file.duration) {
|
||||||
const afChapters =
|
// Multi-file audiobook may include the previous and next chapters embedded with close to 0 duration
|
||||||
file.chapters?.map((c) => ({
|
// Filter these out and log a warning
|
||||||
...c,
|
// See https://github.com/advplyr/audiobookshelf/issues/3361
|
||||||
id: c.id + currChapterId,
|
const afChaptersCleaned =
|
||||||
start: c.start + currStartTime,
|
file.chapters?.filter((c) => {
|
||||||
end: c.end + currStartTime
|
if (c.end - c.start < 0.1) {
|
||||||
})) ?? []
|
libraryScan.addLog(LogLevel.WARN, `Chapter "${c.title}" has invalid duration of ${c.end - c.start} seconds. Skipping this chapter.`)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}) || []
|
||||||
|
const afChapters = afChaptersCleaned.map((c) => ({
|
||||||
|
...c,
|
||||||
|
id: c.id + currChapterId,
|
||||||
|
start: c.start + currStartTime,
|
||||||
|
end: c.end + currStartTime
|
||||||
|
}))
|
||||||
chapters = chapters.concat(afChapters)
|
chapters = chapters.concat(afChapters)
|
||||||
|
|
||||||
currChapterId += file.chapters?.length ?? 0
|
currChapterId += afChaptersCleaned.length ?? 0
|
||||||
currStartTime += file.duration
|
currStartTime += file.duration
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user