Moved getting xml meta entries to opf parser

This commit is contained in:
Igor Kaldowski 2021-12-04 22:15:23 +00:00
parent 60aeb23797
commit 4ac0bd6770
2 changed files with 7 additions and 6 deletions

View File

@ -56,12 +56,6 @@ const xmlToJSON = (xml) => {
Logger.error(`[xmlToJSON] Error`, err)
resolve(null)
} else {
if (typeof results.package.metadata[0].meta != "undefined") {
results.package.metadata[0].meta = {}
for(var match of xml.matchAll(/<meta name="(?<name>.+)" content="(?<content>.+)"\/>/g)) {
results.package.metadata[0].meta[match.groups['name']] = [match.groups['content']]
}
}
resolve(results)
}
})

View File

@ -90,6 +90,13 @@ module.exports.parseOpfMetadataXML = async (xml) => {
metadata = metadata[0]
}
if (typeof metadata.meta != "undefined") {
metadata.meta = {}
for(var match of xml.matchAll(/<meta name="(?<name>.+)" content="(?<content>.+)"\/>/g)) {
metadata.meta[match.groups['name']] = [match.groups['content']]
}
}
var creators = parseCreators(metadata)
var data = {
title: fetchTitle(metadata),