mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-01-19 04:19:02 +01:00
Get series info from opf
This commit is contained in:
parent
9423727f89
commit
6e621ecce1
@ -56,6 +56,12 @@ const xmlToJSON = (xml) => {
|
|||||||
Logger.error(`[xmlToJSON] Error`, err)
|
Logger.error(`[xmlToJSON] Error`, err)
|
||||||
resolve(null)
|
resolve(null)
|
||||||
} else {
|
} 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)
|
resolve(results)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -69,6 +69,16 @@ function fetchLanguage(metadata) {
|
|||||||
return fetchTagString(metadata, 'dc:language')
|
return fetchTagString(metadata, 'dc:language')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function fetchSeries(metadata) {
|
||||||
|
if(typeof metadata.meta == "undefined") return null
|
||||||
|
return fetchTagString(metadata.meta, "calibre:series")
|
||||||
|
}
|
||||||
|
|
||||||
|
function fetchVolumeNumber(metadata) {
|
||||||
|
if(typeof metadata.meta == "undefined") return null
|
||||||
|
return fetchTagString(metadata.meta, "calibre:series_index")
|
||||||
|
}
|
||||||
|
|
||||||
module.exports.parseOpfMetadataXML = async (xml) => {
|
module.exports.parseOpfMetadataXML = async (xml) => {
|
||||||
var json = await xmlToJSON(xml)
|
var json = await xmlToJSON(xml)
|
||||||
if (!json || !json.package || !json.package.metadata) return null
|
if (!json || !json.package || !json.package.metadata) return null
|
||||||
@ -89,7 +99,9 @@ module.exports.parseOpfMetadataXML = async (xml) => {
|
|||||||
isbn: fetchISBN(metadata),
|
isbn: fetchISBN(metadata),
|
||||||
description: fetchDescription(metadata),
|
description: fetchDescription(metadata),
|
||||||
genres: fetchGenres(metadata),
|
genres: fetchGenres(metadata),
|
||||||
language: fetchLanguage(metadata)
|
language: fetchLanguage(metadata),
|
||||||
|
series: fetchSeries(metadata),
|
||||||
|
volumeNumber: fetchVolumeNumber(metadata)
|
||||||
}
|
}
|
||||||
return data
|
return data
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user