diff --git a/server/utils/parseOpfMetadata.js b/server/utils/parseOpfMetadata.js index 83f3e3cb..546cfb54 100644 --- a/server/utils/parseOpfMetadata.js +++ b/server/utils/parseOpfMetadata.js @@ -80,6 +80,17 @@ function fetchVolumeNumber(metadata) { return fetchTagString(metadata.meta, "calibre:series_index") } +function fetchNarrators(creators, metadata) { + var roleNrt = fetchCreator(creators, 'nrt') + if(typeof metadata.meta == "undefined" || roleNrt != null) return roleNrt + 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) => { var json = await xmlToJSON(xml) if (!json || !json.package || !json.package.metadata) return null @@ -101,7 +112,7 @@ module.exports.parseOpfMetadataXML = async (xml) => { var data = { title: fetchTitle(metadata), author: fetchCreator(creators, 'aut'), - narrator: fetchCreator(creators, 'nrt'), + narrator: fetchNarrators(creators, metadata), publishYear: fetchDate(metadata), publisher: fetchPublisher(metadata), isbn: fetchISBN(metadata),