diff --git a/server/scanner/AudioFileScanner.js b/server/scanner/AudioFileScanner.js index 00bd44d3..73324b72 100644 --- a/server/scanner/AudioFileScanner.js +++ b/server/scanner/AudioFileScanner.js @@ -499,16 +499,17 @@ class AudioFileScanner { // Filter these out and log a warning // See https://github.com/advplyr/audiobookshelf/issues/3361 const afChaptersCleaned = - file.chapters?.filter((c) => { + file.chapters?.filter((c, i) => { 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.`) + libraryScan.addLog(LogLevel.WARN, `Audio file "${file.metadata.filename}" Chapter "${c.title}" (index ${i}) has invalid duration of ${c.end - c.start} seconds. Skipping this chapter.`) return false } return true }) || [] - const afChapters = afChaptersCleaned.map((c) => ({ + + const afChapters = afChaptersCleaned.map((c, i) => ({ ...c, - id: c.id + currChapterId, + id: currChapterId + i, start: c.start + currStartTime, end: c.end + currStartTime })) diff --git a/server/utils/prober.js b/server/utils/prober.js index 838899bd..40a3b5b5 100644 --- a/server/utils/prober.js +++ b/server/utils/prober.js @@ -143,6 +143,7 @@ function parseChapters(_chapters) { .map((chap) => { let title = chap['TAG:title'] || chap.title || '' if (!title && chap.tags?.title) title = chap.tags.title + title = title.trim() const timebase = chap.time_base?.includes('/') ? Number(chap.time_base.split('/')[1]) : 1 const start = !isNullOrNaN(chap.start_time) ? Number(chap.start_time) : !isNullOrNaN(chap.start) ? Number(chap.start) / timebase : 0