Cleaned series match & renaming volumeNumber to sequence

This commit is contained in:
advplyr 2022-10-01 17:01:22 -05:00
parent c23f31216a
commit 14e5e11344
5 changed files with 13 additions and 24 deletions

View File

@ -19,7 +19,7 @@
<div v-if="book.series && book.series.length" class="flex py-1 -mx-1">
<div v-for="(series, index) in book.series" :key="index" class="bg-white bg-opacity-10 rounded-full px-1 py-0.5 mx-1">
<p class="leading-3 text-xs text-gray-400">
{{ series.series }}<span v-if="series.volumeNumber">&nbsp;#{{ series.volumeNumber }}</span>
{{ series.series }}<span v-if="series.sequence">&nbsp;#{{ series.sequence }}</span>
</p>
</div>
</div>

View File

@ -182,7 +182,8 @@ export default {
return this.mediaType === 'podcast'
},
placeholderUrl() {
return `${this.$config.routerBasePath}/book_placeholder.jpg`
const config = this.$config || this.$nuxt.$config
return `${config.routerBasePath}/book_placeholder.jpg`
},
bookCoverSrc() {
return this.store.getters['globals/getLibraryItemCoverSrc'](this._libraryItem, this.placeholderUrl)

View File

@ -100,10 +100,6 @@
<p v-if="mediaMetadata.seriesName" class="text-xs ml-1 text-white text-opacity-60">Currently: {{ mediaMetadata.seriesName || '' }}</p>
</div>
</div>
<div v-if="selectedMatchOrig.volumeNumber" class="flex items-center py-2">
<ui-checkbox v-model="selectedMatchUsage.volumeNumber" @input="checkboxToggled" />
<ui-text-input-with-label v-model="selectedMatch.volumeNumber" :disabled="!selectedMatchUsage.volumeNumber" label="Volume Number" class="flex-grow ml-4" />
</div>
<div v-if="selectedMatchOrig.genres && selectedMatchOrig.genres.length" class="flex items-center py-2">
<ui-checkbox v-model="selectedMatchUsage.genres" checkbox-bg="bg" @input="checkboxToggled" />
<div class="flex-grow ml-4">
@ -208,7 +204,6 @@ export default {
publisher: true,
publishedYear: true,
series: true,
volumeNumber: true,
genres: true,
tags: true,
language: true,
@ -246,9 +241,9 @@ export default {
return this.selectedMatch.series.map((se) => {
return {
id: `new-${Math.floor(Math.random() * 10000)}`,
displayName: se.volumeNumber ? `${se.series} #${se.volumeNumber}` : se.series,
displayName: se.sequence ? `${se.series} #${se.sequence}` : se.series,
name: se.series,
sequence: se.volumeNumber || ''
sequence: se.sequence || ''
}
})
},
@ -353,7 +348,6 @@ export default {
publisher: true,
publishedYear: true,
series: true,
volumeNumber: true,
genres: true,
tags: true,
language: true,
@ -396,9 +390,9 @@ export default {
match.series = match.series.map((se) => {
return {
id: `new-${Math.floor(Math.random() * 10000)}`,
displayName: se.volumeNumber ? `${se.series} #${se.volumeNumber}` : se.series,
displayName: se.sequence ? `${se.series} #${se.sequence}` : se.series,
name: se.series,
sequence: se.volumeNumber || ''
sequence: se.sequence || ''
}
})
}
@ -417,18 +411,13 @@ export default {
var updatePayload = {}
updatePayload.metadata = {}
var volumeNumber = this.selectedMatchUsage.volumeNumber ? this.selectedMatch.volumeNumber || null : null
for (const key in this.selectedMatchUsage) {
if (this.selectedMatchUsage[key] && this.selectedMatch[key]) {
if (key === 'series') {
var seriesPayload = []
if (!Array.isArray(this.selectedMatch[key])) {
seriesPayload.push({
id: `new-${Math.floor(Math.random() * 10000)}`,
name: this.selectedMatch[key],
sequence: volumeNumber
})
console.error('Invalid series in selectedMatch', this.selectedMatch[key])
} else {
var seriesPayload = []
this.selectedMatch[key].forEach((seriesItem) =>
seriesPayload.push({
id: seriesItem.id,
@ -436,9 +425,8 @@ export default {
sequence: seriesItem.sequence
})
)
updatePayload.metadata.series = seriesPayload
}
updatePayload.metadata.series = seriesPayload
} else if (key === 'author' && !this.isPodcast) {
var authors = this.selectedMatch[key]
if (!Array.isArray(authors)) {

View File

@ -27,7 +27,7 @@ class Audible {
asin,
genres: genresFiltered.length ? genresFiltered : null,
tags: tagsFiltered.length ? tagsFiltered.join(', ') : null,
series: series != [] ? series.map(({ name, position }) => ({ series: name, volumeNumber: position })) : null,
series: series != [] ? series.map(({ name, position }) => ({ series: name, sequence: position })) : null,
language: language ? language.charAt(0).toUpperCase() + language.slice(1) : null,
duration: runtimeLengthMin && !isNaN(runtimeLengthMin) ? Number(runtimeLengthMin) : 0
}

View File

@ -850,7 +850,7 @@ class Scanner {
// Add or set series if not set
if (matchData.series && (!libraryItem.media.metadata.seriesName || options.overrideDetails)) {
if (!Array.isArray(matchData.series)) matchData.series = [{ series: matchData.series, volumeNumber: matchData.volumeNumber }]
if (!Array.isArray(matchData.series)) matchData.series = [{ series: matchData.series, sequence: matchData.sequence }]
const seriesPayload = []
for (let index = 0; index < matchData.series.length; index++) {
const seriesMatchItem = matchData.series[index]
@ -861,7 +861,7 @@ class Scanner {
await this.db.insertEntity('series', seriesItem)
this.emitter('series_added', seriesItem)
}
seriesPayload.push(seriesItem.toJSONMinimal(seriesMatchItem.volumeNumber))
seriesPayload.push(seriesItem.toJSONMinimal(seriesMatchItem.sequence))
}
updatePayload.metadata.series = seriesPayload
}