mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-07-14 11:25:02 +02:00
This commit is contained in:
parent
c7b0e1e2a2
commit
fa8d02c729
8 changed files with 150 additions and 6 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue