mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-01-03 00:06:46 +01:00
Update:Scanner folder name parse sequence starting with decimal and cast to number
This commit is contained in:
parent
cd57667444
commit
6a6d384d88
@ -254,6 +254,7 @@ function getBookDataFromDir(folderPath, relPath, parseSubtitle = false) {
|
|||||||
path: Path.posix.join(folderPath, relPath) // i.e. /audiobook/Author Name/Book Name/..
|
path: Path.posix.join(folderPath, relPath) // i.e. /audiobook/Author Name/Book Name/..
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
module.exports.getBookDataFromDir = getBookDataFromDir
|
||||||
|
|
||||||
function getNarrator(folder) {
|
function getNarrator(folder) {
|
||||||
let pattern = /^(?<title>.*) \{(?<narrators>.*)\}$/
|
let pattern = /^(?<title>.*) \{(?<narrators>.*)\}$/
|
||||||
@ -277,16 +278,15 @@ function getSequence(folder) {
|
|||||||
// ]
|
// ]
|
||||||
|
|
||||||
// Matches a valid volume string. Also matches a book whose title starts with a 1 to 3 digit number. Will handle that later.
|
// Matches a valid volume string. Also matches a book whose title starts with a 1 to 3 digit number. Will handle that later.
|
||||||
let pattern = /^(?<volumeLabel>vol\.? |volume |book )?(?<sequence>\d{1,3}(?:\.\d{1,2})?)(?<trailingDot>\.?)(?: (?<suffix>.*))?$/i
|
let pattern = /^(?<volumeLabel>vol\.? |volume |book )?(?<sequence>\d{0,3}(?:\.\d{1,2})?)(?<trailingDot>\.?)(?: (?<suffix>.*))?$/i
|
||||||
|
|
||||||
let volumeNumber = null
|
let volumeNumber = null
|
||||||
let parts = folder.split(' - ')
|
let parts = folder.split(' - ')
|
||||||
for (let i = 0; i < parts.length; i++) {
|
for (let i = 0; i < parts.length; i++) {
|
||||||
let match = parts[i].match(pattern)
|
let match = parts[i].match(pattern)
|
||||||
|
|
||||||
// This excludes '101 Dalmations' but includes '101. Dalmations'
|
// This excludes '101 Dalmations' but includes '101. Dalmations'
|
||||||
if (match && !(match.groups.suffix && !(match.groups.volumeLabel || match.groups.trailingDot))) {
|
if (match && !(match.groups.suffix && !(match.groups.volumeLabel || match.groups.trailingDot))) {
|
||||||
volumeNumber = match.groups.sequence
|
volumeNumber = isNaN(match.groups.sequence) ? match.groups.sequence : Number(match.groups.sequence).toString()
|
||||||
parts[i] = match.groups.suffix
|
parts[i] = match.groups.suffix
|
||||||
if (!parts[i]) { parts.splice(i, 1) }
|
if (!parts[i]) { parts.splice(i, 1) }
|
||||||
break
|
break
|
||||||
@ -338,7 +338,7 @@ function getDataFromMediaDir(libraryMediaType, folderPath, relPath, serverSettin
|
|||||||
var parseSubtitle = !!serverSettings.scannerParseSubtitle
|
var parseSubtitle = !!serverSettings.scannerParseSubtitle
|
||||||
return getBookDataFromDir(folderPath, relPath, parseSubtitle)
|
return getBookDataFromDir(folderPath, relPath, parseSubtitle)
|
||||||
} else {
|
} else {
|
||||||
return this.getPodcastDataFromDir(folderPath, relPath)
|
return getPodcastDataFromDir(folderPath, relPath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user