From 4212251c7858726ecb93ee3d26a416340f3c4eb5 Mon Sep 17 00:00:00 2001 From: Igor Kaldowski Date: Tue, 1 Feb 2022 16:50:42 +0000 Subject: [PATCH] Added try catch to opf fetchNarrators --- server/utils/parseOpfMetadata.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/server/utils/parseOpfMetadata.js b/server/utils/parseOpfMetadata.js index 2ff20ccf..546cfb54 100644 --- a/server/utils/parseOpfMetadata.js +++ b/server/utils/parseOpfMetadata.js @@ -83,10 +83,12 @@ function fetchVolumeNumber(metadata) { function fetchNarrators(creators, metadata) { var roleNrt = fetchCreator(creators, 'nrt') if(typeof metadata.meta == "undefined" || roleNrt != null) return roleNrt - var narratorsTag = fetchTagString(metadata.meta, "calibre:user_metadata:#narrators") - if(narratorsTag == null) return narratorsTag - var narratorsJSON = JSON.parse(narratorsTag.replace(/"/g,'"')) - return narratorsJSON["#value#"].join(", ") + try { + var narratorsJSON = JSON.parse(fetchTagString(metadata.meta, "calibre:user_metadata:#narrators").replace(/"/g,'"')) + return narratorsJSON["#value#"].join(", ") + } catch { + return null + } } module.exports.parseOpfMetadataXML = async (xml) => {