mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-12-15 08:19:37 +00:00
Add: Support multiple narrator parse and filter #182
This commit is contained in:
parent
bf2b534170
commit
979fb70c31
4 changed files with 53 additions and 5 deletions
|
|
@ -54,6 +54,7 @@ class Book {
|
|||
this.authorFL = book.authorFL || null
|
||||
this.authorLF = book.authorLF || null
|
||||
this.narrator = book.narrator || book.narrarator || null // Mispelled initially... need to catch those
|
||||
this.narratorFL = book.narratorFL || null
|
||||
this.series = book.series
|
||||
this.volumeNumber = book.volumeNumber || null
|
||||
this.publishYear = book.publishYear
|
||||
|
|
@ -68,6 +69,11 @@ class Book {
|
|||
this.lastCoverSearch = book.lastCoverSearch || null
|
||||
this.lastCoverSearchTitle = book.lastCoverSearchTitle || null
|
||||
this.lastCoverSearchAuthor = book.lastCoverSearchAuthor || null
|
||||
|
||||
// narratorFL added in v1.6.21 to support multi-narrators
|
||||
if (this.narrator && !this.narratorFL) {
|
||||
this.setParseNarrator(this.narrator)
|
||||
}
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
|
|
@ -78,6 +84,7 @@ class Book {
|
|||
authorFL: this.authorFL,
|
||||
authorLF: this.authorLF,
|
||||
narrator: this.narrator,
|
||||
narratorFL: this.narratorFL,
|
||||
series: this.series,
|
||||
volumeNumber: this.volumeNumber,
|
||||
publishYear: this.publishYear,
|
||||
|
|
@ -114,6 +121,23 @@ class Book {
|
|||
}
|
||||
}
|
||||
|
||||
setParseNarrator(narrator) {
|
||||
if (!narrator) {
|
||||
var hasUpdated = this.narratorFL
|
||||
this.narratorFL = null
|
||||
return hasUpdated
|
||||
}
|
||||
try {
|
||||
var { authorFL } = parseAuthors(narrator)
|
||||
var hasUpdated = authorFL !== this.narratorFL
|
||||
this.narratorFL = authorFL || null
|
||||
return hasUpdated
|
||||
} catch (err) {
|
||||
Logger.error('[Book] Parse narrator failed', err)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
setData(data) {
|
||||
this.title = data.title || null
|
||||
this.subtitle = data.subtitle || null
|
||||
|
|
@ -136,6 +160,9 @@ class Book {
|
|||
if (data.author) {
|
||||
this.setParseAuthor(this.author)
|
||||
}
|
||||
if (data.narrator) {
|
||||
this.setParseNarrator(this.narrator)
|
||||
}
|
||||
}
|
||||
|
||||
update(payload) {
|
||||
|
|
@ -174,6 +201,14 @@ class Book {
|
|||
if (this.setParseAuthor(this.author)) {
|
||||
hasUpdates = true
|
||||
}
|
||||
} else if (key === 'narrator') {
|
||||
if (this.narrator !== payload.narrator) {
|
||||
this.narrator = payload.narrator || null
|
||||
hasUpdates = true
|
||||
}
|
||||
if (this.setParseNarrator(this.narrator)) {
|
||||
hasUpdates = true
|
||||
}
|
||||
} else if (this[key] !== undefined && payload[key] !== this[key]) {
|
||||
this[key] = payload[key]
|
||||
hasUpdates = true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue