mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-06-26 10:49:00 +02:00
Update:Book series embeds in grouping meta tag as semicolon deliminated, book meta tag parser falls back to using grouping tag for series if set #3473
This commit is contained in:
parent
72e59e77a7
commit
953ffe889e
6 changed files with 65 additions and 27 deletions
27
server/utils/parsers/parseSeriesString.js
Normal file
27
server/utils/parsers/parseSeriesString.js
Normal file
|
@ -0,0 +1,27 @@
|
|||
/**
|
||||
* Parse a series string into a name and sequence
|
||||
*
|
||||
* @example
|
||||
* Name #1a => { name: 'Name', sequence: '1a' }
|
||||
* Name #1 => { name: 'Name', sequence: '1' }
|
||||
*
|
||||
* @param {string} seriesString
|
||||
* @returns {{name: string, sequence: string}|null}
|
||||
*/
|
||||
module.exports.parse = (seriesString) => {
|
||||
if (!seriesString || typeof seriesString !== 'string') return null
|
||||
|
||||
let sequence = null
|
||||
let name = seriesString
|
||||
// Series sequence match any characters after " #" other than whitespace and another #
|
||||
// e.g. "Name #1a" is valid. "Name #1#a" or "Name #1 a" is not valid.
|
||||
const matchResults = seriesString.match(/ #([^#\s]+)$/) // Pull out sequence #
|
||||
if (matchResults && matchResults.length && matchResults.length > 1) {
|
||||
sequence = matchResults[1] // Group 1
|
||||
name = seriesString.replace(matchResults[0], '')
|
||||
}
|
||||
return {
|
||||
name,
|
||||
sequence
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue