Merge pull request #343 from igorkaldowski/master

Fetch Narrators from opf custom column
This commit is contained in:
advplyr 2022-02-01 14:36:28 -06:00 committed by GitHub
commit 316ae4ff79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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),