mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-01-22 00:07:52 +01:00
Add: Support multiple narrator parse and filter #182
This commit is contained in:
parent
bf2b534170
commit
979fb70c31
@ -30,7 +30,11 @@
|
|||||||
<span class="text-white text-opacity-60 uppercase text-sm">Narrated By</span>
|
<span class="text-white text-opacity-60 uppercase text-sm">Narrated By</span>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<nuxt-link :to="`/library/${libraryId}/bookshelf?filter=narrators.${$encode(narrator)}`" class="hover:underline">{{ narrator }}</nuxt-link>
|
<template v-for="(narrator, index) in narrators">
|
||||||
|
<nuxt-link :key="narrator" :to="`/library/${libraryId}/bookshelf?filter=narrators.${$encode(narrator)}`" class="hover:underline">{{ narrator }}</nuxt-link
|
||||||
|
><span :key="index" v-if="index < narrators.length - 1">, </span>
|
||||||
|
</template>
|
||||||
|
<!-- <nuxt-link :to="`/library/${libraryId}/bookshelf?filter=narrators.${$encode(narrator)}`" class="hover:underline">{{ narrator }}</nuxt-link> -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="publishYear" class="flex py-0.5">
|
<div v-if="publishYear" class="flex py-0.5">
|
||||||
@ -278,6 +282,10 @@ export default {
|
|||||||
authorLF() {
|
authorLF() {
|
||||||
return this.book.authorLF
|
return this.book.authorLF
|
||||||
},
|
},
|
||||||
|
narrators() {
|
||||||
|
if (!this.book.narratorFL) return []
|
||||||
|
return this.book.narratorFL.split(', ') || []
|
||||||
|
},
|
||||||
authorTooltipText() {
|
authorTooltipText() {
|
||||||
var txt = ['FL: ' + this.authorFL || 'Not Set', 'LF: ' + this.authorLF || 'Not Set']
|
var txt = ['FL: ' + this.authorFL || 'Not Set', 'LF: ' + this.authorLF || 'Not Set']
|
||||||
return txt.join('<br>')
|
return txt.join('<br>')
|
||||||
|
@ -60,7 +60,7 @@ export const getters = {
|
|||||||
else filtered = filtered.filter(ab => ab.book && ab.book.series === filter)
|
else filtered = filtered.filter(ab => ab.book && ab.book.series === filter)
|
||||||
}
|
}
|
||||||
else if (group === 'authors') filtered = filtered.filter(ab => ab.book && ab.book.authorFL && ab.book.authorFL.split(', ').includes(filter))
|
else if (group === 'authors') filtered = filtered.filter(ab => ab.book && ab.book.authorFL && ab.book.authorFL.split(', ').includes(filter))
|
||||||
else if (group === 'narrators') filtered = filtered.filter(ab => ab.book && ab.book.narrator === filter)
|
else if (group === 'narrators') filtered = filtered.filter(ab => ab.book && ab.book.narratorFL && ab.book.narratorFL.split(', ').includes(filter))
|
||||||
else if (group === 'progress') {
|
else if (group === 'progress') {
|
||||||
filtered = filtered.filter(ab => {
|
filtered = filtered.filter(ab => {
|
||||||
var userAudiobook = rootGetters['user/getUserAudiobook'](ab.id)
|
var userAudiobook = rootGetters['user/getUserAudiobook'](ab.id)
|
||||||
@ -141,8 +141,13 @@ export const getters = {
|
|||||||
return [...new Set(abAuthors)].sort((a, b) => a.toLowerCase() < b.toLowerCase() ? -1 : 1)
|
return [...new Set(abAuthors)].sort((a, b) => a.toLowerCase() < b.toLowerCase() ? -1 : 1)
|
||||||
},
|
},
|
||||||
getUniqueNarrators: (state) => {
|
getUniqueNarrators: (state) => {
|
||||||
var _narrators = state.audiobooks.filter(ab => !!(ab.book && ab.book.narrator)).map(ab => ab.book.narrator)
|
var narrators = []
|
||||||
return [...new Set(_narrators)].sort((a, b) => a.toLowerCase() < b.toLowerCase() ? -1 : 1)
|
state.audiobooks.forEach((ab) => {
|
||||||
|
if (ab.book && ab.book.narratorFL) {
|
||||||
|
narrators = narrators.concat(ab.book.narratorFL.split(', '))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return [...new Set(narrators)].sort((a, b) => a.toLowerCase() < b.toLowerCase() ? -1 : 1)
|
||||||
},
|
},
|
||||||
getGenresUsed: (state) => {
|
getGenresUsed: (state) => {
|
||||||
var _genres = []
|
var _genres = []
|
||||||
|
@ -54,6 +54,7 @@ class Book {
|
|||||||
this.authorFL = book.authorFL || null
|
this.authorFL = book.authorFL || null
|
||||||
this.authorLF = book.authorLF || null
|
this.authorLF = book.authorLF || null
|
||||||
this.narrator = book.narrator || book.narrarator || null // Mispelled initially... need to catch those
|
this.narrator = book.narrator || book.narrarator || null // Mispelled initially... need to catch those
|
||||||
|
this.narratorFL = book.narratorFL || null
|
||||||
this.series = book.series
|
this.series = book.series
|
||||||
this.volumeNumber = book.volumeNumber || null
|
this.volumeNumber = book.volumeNumber || null
|
||||||
this.publishYear = book.publishYear
|
this.publishYear = book.publishYear
|
||||||
@ -68,6 +69,11 @@ class Book {
|
|||||||
this.lastCoverSearch = book.lastCoverSearch || null
|
this.lastCoverSearch = book.lastCoverSearch || null
|
||||||
this.lastCoverSearchTitle = book.lastCoverSearchTitle || null
|
this.lastCoverSearchTitle = book.lastCoverSearchTitle || null
|
||||||
this.lastCoverSearchAuthor = book.lastCoverSearchAuthor || 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() {
|
toJSON() {
|
||||||
@ -78,6 +84,7 @@ class Book {
|
|||||||
authorFL: this.authorFL,
|
authorFL: this.authorFL,
|
||||||
authorLF: this.authorLF,
|
authorLF: this.authorLF,
|
||||||
narrator: this.narrator,
|
narrator: this.narrator,
|
||||||
|
narratorFL: this.narratorFL,
|
||||||
series: this.series,
|
series: this.series,
|
||||||
volumeNumber: this.volumeNumber,
|
volumeNumber: this.volumeNumber,
|
||||||
publishYear: this.publishYear,
|
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) {
|
setData(data) {
|
||||||
this.title = data.title || null
|
this.title = data.title || null
|
||||||
this.subtitle = data.subtitle || null
|
this.subtitle = data.subtitle || null
|
||||||
@ -136,6 +160,9 @@ class Book {
|
|||||||
if (data.author) {
|
if (data.author) {
|
||||||
this.setParseAuthor(this.author)
|
this.setParseAuthor(this.author)
|
||||||
}
|
}
|
||||||
|
if (data.narrator) {
|
||||||
|
this.setParseNarrator(this.narrator)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
update(payload) {
|
update(payload) {
|
||||||
@ -174,6 +201,14 @@ class Book {
|
|||||||
if (this.setParseAuthor(this.author)) {
|
if (this.setParseAuthor(this.author)) {
|
||||||
hasUpdates = true
|
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]) {
|
} else if (this[key] !== undefined && payload[key] !== this[key]) {
|
||||||
this[key] = payload[key]
|
this[key] = payload[key]
|
||||||
hasUpdates = true
|
hasUpdates = true
|
||||||
|
@ -44,7 +44,7 @@ module.exports = (author) => {
|
|||||||
var isEvenNum = splitAuthors.length % 2 === 0
|
var isEvenNum = splitAuthors.length % 2 === 0
|
||||||
|
|
||||||
if (!isEvenNum && firstChunkIsALastName) {
|
if (!isEvenNum && firstChunkIsALastName) {
|
||||||
// console.error('Multi-author LAST,FIRST entry has a straggler (could be roman numerals or a suffix), ignore it', splitByComma[splitByComma.length - 1])
|
// console.error('Multi-author LAST,FIRST entry has a straggler (could be roman numerals or a suffix), ignore it')
|
||||||
splitAuthors = splitAuthors.slice(0, splitAuthors.length - 1)
|
splitAuthors = splitAuthors.slice(0, splitAuthors.length - 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user