From 40b808e73da2fb3290ca5fd8b939411d16d5ab1d Mon Sep 17 00:00:00 2001 From: advplyr Date: Mon, 13 Mar 2023 17:56:16 -0500 Subject: [PATCH] Update:Use title ID3 tag on tracks when setting chapters and prefer audio metadata setting is enabled #679 --- server/objects/mediaTypes/Book.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/server/objects/mediaTypes/Book.js b/server/objects/mediaTypes/Book.js index 8bf1b379..2983faf7 100644 --- a/server/objects/mediaTypes/Book.js +++ b/server/objects/mediaTypes/Book.js @@ -462,13 +462,20 @@ class Book { }) } } else if (includedAudioFiles.length > 1) { + const preferAudioMetadata = !!global.ServerSettings.scannerPreferAudioMetadata + // Build chapters from audio files this.chapters = [] let currChapterId = 0 let currStartTime = 0 includedAudioFiles.forEach((file) => { if (file.duration) { - const title = file.metadata.filename ? Path.basename(file.metadata.filename, Path.extname(file.metadata.filename)) : `Chapter ${currChapterId}` + let title = file.metadata.filename ? Path.basename(file.metadata.filename, Path.extname(file.metadata.filename)) : `Chapter ${currChapterId}` + + // When prefer audio metadata server setting is set then use ID3 title tag as long as it is not the same as the book title + if (preferAudioMetadata && file.metaTags?.tagTitle && file.metaTags?.tagTitle !== this.metadata.title) { + title = file.metaTags.tagTitle + } this.chapters.push({ id: currChapterId++,