Fix: books read stat #167, Add: scanner parse metadata.opf and metadata.xml and use data #141

This commit is contained in:
advplyr 2021-11-08 20:05:12 -06:00
parent c7b0e1e2a2
commit fa8d02c729
8 changed files with 150 additions and 6 deletions

View file

@ -1,6 +1,7 @@
const Path = require('path')
const fs = require('fs')
const Logger = require('../Logger')
const { parseString } = require("xml2js")
const levenshteinDistance = (str1, str2, caseSensitive = false) => {
if (!caseSensitive) {
@ -43,3 +44,17 @@ module.exports.getIno = (path) => {
return null
})
}
const xmlToJSON = (xml) => {
return new Promise((resolve, reject) => {
parseString(xml, (err, results) => {
if (err) {
Logger.error(`[xmlToJSON] Error`, err)
resolve(null)
} else {
resolve(results)
}
})
})
}
module.exports.xmlToJSON = xmlToJSON