diff --git a/server/objects/metadata/BookMetadata.js b/server/objects/metadata/BookMetadata.js index 59204777..99be71f6 100644 --- a/server/objects/metadata/BookMetadata.js +++ b/server/objects/metadata/BookMetadata.js @@ -194,7 +194,7 @@ class BookMetadata { setData(scanMediaData = {}) { this.title = scanMediaData.title || null this.subtitle = scanMediaData.subtitle || null - this.narrators = [] + this.narrators = this.parseNarratorsTag(scanMediaData.narrators) this.publishedYear = scanMediaData.publishedYear || null this.description = scanMediaData.description || null this.isbn = scanMediaData.isbn || null @@ -356,4 +356,4 @@ class BookMetadata { return null } } -module.exports = BookMetadata \ No newline at end of file +module.exports = BookMetadata diff --git a/server/utils/scandir.js b/server/utils/scandir.js index 3bcfbc35..9d52227a 100644 --- a/server/utils/scandir.js +++ b/server/utils/scandir.js @@ -212,7 +212,8 @@ function getBookDataFromDir(folderPath, relPath, parseSubtitle = false) { var splitDir = relPath.split('/') // Audio files will always be in the directory named for the title - var title = splitDir.pop() + var [title, narrators] = getTitleAndNarrator(splitDir.pop()) + var series = null var author = null // If there are at least 2 more directories, next furthest will be the series @@ -265,7 +266,7 @@ function getBookDataFromDir(folderPath, relPath, parseSubtitle = false) { // If Title is of format 1999 OR (1999) - Title, then use 1999 as publish year var publishYearMatch = title.match(/^(\(?[0-9]{4}\)?) - (.+)/) if (publishYearMatch && publishYearMatch.length > 2 && publishYearMatch[1]) { - // Strip parentheses + // Strip parentheses if (publishYearMatch[1].startsWith('(') && publishYearMatch[1].endsWith(')')) { publishYearMatch[1] = publishYearMatch[1].slice(1, -1) } @@ -292,12 +293,19 @@ function getBookDataFromDir(folderPath, relPath, parseSubtitle = false) { series, sequence: volumeNumber, publishedYear, + narrators, }, relPath: relPath, // relative audiobook path i.e. /Author Name/Book Name/.. path: Path.posix.join(folderPath, relPath) // i.e. /audiobook/Author Name/Book Name/.. } } +function getTitleAndNarrator(folder) { + let pattern = /^(?