mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-01-03 00:06:46 +01:00
Fix:OPF parser crash when no narrators #1578
This commit is contained in:
parent
aef2c52630
commit
3df7caa838
@ -296,7 +296,7 @@ class Book {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else if (key === 'narrators') {
|
} else if (key === 'narrators') {
|
||||||
if (opfMetadata.narrators && opfMetadata.narrators.length && (!this.metadata.narrators.length || opfMetadataOverrideDetails)) {
|
if (opfMetadata.narrators?.length && (!this.metadata.narrators.length || opfMetadataOverrideDetails)) {
|
||||||
metadataUpdatePayload.narrators = opfMetadata.narrators
|
metadataUpdatePayload.narrators = opfMetadata.narrators
|
||||||
}
|
}
|
||||||
} else if (key === 'series') {
|
} else if (key === 'series') {
|
||||||
|
@ -111,7 +111,7 @@ function fetchVolumeNumber(metadataMeta) {
|
|||||||
|
|
||||||
function fetchNarrators(creators, metadata) {
|
function fetchNarrators(creators, metadata) {
|
||||||
const narrators = fetchCreators(creators, 'nrt')
|
const narrators = fetchCreators(creators, 'nrt')
|
||||||
if (typeof metadata.meta == "undefined" || narrators.length) return narrators
|
if (narrators?.length) return narrators
|
||||||
try {
|
try {
|
||||||
const narratorsJSON = JSON.parse(fetchTagString(metadata.meta, "calibre:user_metadata:#narrators").replace(/"/g, '"'))
|
const narratorsJSON = JSON.parse(fetchTagString(metadata.meta, "calibre:user_metadata:#narrators").replace(/"/g, '"'))
|
||||||
return narratorsJSON["#value#"]
|
return narratorsJSON["#value#"]
|
||||||
@ -150,7 +150,7 @@ module.exports.parseOpfMetadataXML = async (xml) => {
|
|||||||
const metadataMeta = prefix ? metadata[`${prefix}:meta`] || metadata.meta : metadata.meta
|
const metadataMeta = prefix ? metadata[`${prefix}:meta`] || metadata.meta : metadata.meta
|
||||||
|
|
||||||
metadata.meta = {}
|
metadata.meta = {}
|
||||||
if (metadataMeta && metadataMeta.length) {
|
if (metadataMeta?.length) {
|
||||||
metadataMeta.forEach((meta) => {
|
metadataMeta.forEach((meta) => {
|
||||||
if (meta && meta['$'] && meta['$'].name) {
|
if (meta && meta['$'] && meta['$'].name) {
|
||||||
metadata.meta[meta['$'].name] = [meta['$'].content || '']
|
metadata.meta[meta['$'].name] = [meta['$'].content || '']
|
||||||
|
Loading…
Reference in New Issue
Block a user