Fetch Narrators from opf custom column

This commit is contained in:
Igor Kaldowski 2022-02-01 02:32:03 +00:00
parent 812818bdff
commit 4e329a3f8e

View File

@ -80,6 +80,15 @@ 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
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(", ")
}
module.exports.parseOpfMetadataXML = async (xml) => {
var json = await xmlToJSON(xml)
if (!json || !json.package || !json.package.metadata) return null
@ -101,7 +110,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),