diff --git a/server/objects/mediaTypes/Book.js b/server/objects/mediaTypes/Book.js index 3fa4c1be..b25938ca 100644 --- a/server/objects/mediaTypes/Book.js +++ b/server/objects/mediaTypes/Book.js @@ -296,7 +296,7 @@ class Book { }) } } 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 } } else if (key === 'series') { diff --git a/server/utils/parsers/parseOpfMetadata.js b/server/utils/parsers/parseOpfMetadata.js index f51a7e93..6788faae 100644 --- a/server/utils/parsers/parseOpfMetadata.js +++ b/server/utils/parsers/parseOpfMetadata.js @@ -111,7 +111,7 @@ function fetchVolumeNumber(metadataMeta) { function fetchNarrators(creators, metadata) { const narrators = fetchCreators(creators, 'nrt') - if (typeof metadata.meta == "undefined" || narrators.length) return narrators + if (narrators?.length) return narrators try { const narratorsJSON = JSON.parse(fetchTagString(metadata.meta, "calibre:user_metadata:#narrators").replace(/"/g, '"')) return narratorsJSON["#value#"] @@ -150,7 +150,7 @@ module.exports.parseOpfMetadataXML = async (xml) => { const metadataMeta = prefix ? metadata[`${prefix}:meta`] || metadata.meta : metadata.meta metadata.meta = {} - if (metadataMeta && metadataMeta.length) { + if (metadataMeta?.length) { metadataMeta.forEach((meta) => { if (meta && meta['$'] && meta['$'].name) { metadata.meta[meta['$'].name] = [meta['$'].content || '']