mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-01-08 00:08:14 +01:00
Autoformat parseComicMetadata
This commit is contained in:
parent
26d2c5a8f0
commit
4de65b4369
@ -7,12 +7,12 @@ const { xmlToJSON } = require('../index')
|
|||||||
const parseComicInfoMetadata = require('./parseComicInfoMetadata')
|
const parseComicInfoMetadata = require('./parseComicInfoMetadata')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param {string} filepath
|
* @param {string} filepath
|
||||||
* @returns {Promise<Buffer>}
|
* @returns {Promise<Buffer>}
|
||||||
*/
|
*/
|
||||||
async function getComicFileBuffer(filepath) {
|
async function getComicFileBuffer(filepath) {
|
||||||
if (!await fs.pathExists(filepath)) {
|
if (!(await fs.pathExists(filepath))) {
|
||||||
Logger.error(`Comic path does not exist "${filepath}"`)
|
Logger.error(`Comic path does not exist "${filepath}"`)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
@ -26,10 +26,10 @@ async function getComicFileBuffer(filepath) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Extract cover image from comic return true if success
|
* Extract cover image from comic return true if success
|
||||||
*
|
*
|
||||||
* @param {string} comicPath
|
* @param {string} comicPath
|
||||||
* @param {string} comicImageFilepath
|
* @param {string} comicImageFilepath
|
||||||
* @param {string} outputCoverPath
|
* @param {string} outputCoverPath
|
||||||
* @returns {Promise<boolean>}
|
* @returns {Promise<boolean>}
|
||||||
*/
|
*/
|
||||||
async function extractCoverImage(comicPath, comicImageFilepath, outputCoverPath) {
|
async function extractCoverImage(comicPath, comicImageFilepath, outputCoverPath) {
|
||||||
@ -56,8 +56,8 @@ module.exports.extractCoverImage = extractCoverImage
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse metadata from comic
|
* Parse metadata from comic
|
||||||
*
|
*
|
||||||
* @param {import('../../models/Book').EBookFileObject} ebookFile
|
* @param {import('../../models/Book').EBookFileObject} ebookFile
|
||||||
* @returns {Promise<import('./parseEbookMetadata').EBookFileScanData>}
|
* @returns {Promise<import('./parseEbookMetadata').EBookFileScanData>}
|
||||||
*/
|
*/
|
||||||
async function parse(ebookFile) {
|
async function parse(ebookFile) {
|
||||||
@ -79,7 +79,7 @@ async function parse(ebookFile) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
let metadata = null
|
let metadata = null
|
||||||
const comicInfo = fileObjects.find(fo => fo.file.name === 'ComicInfo.xml')
|
const comicInfo = fileObjects.find((fo) => fo.file.name === 'ComicInfo.xml')
|
||||||
if (comicInfo) {
|
if (comicInfo) {
|
||||||
const comicInfoEntry = await comicInfo.file.extract()
|
const comicInfoEntry = await comicInfo.file.extract()
|
||||||
if (comicInfoEntry?.fileData) {
|
if (comicInfoEntry?.fileData) {
|
||||||
@ -97,7 +97,7 @@ async function parse(ebookFile) {
|
|||||||
metadata
|
metadata
|
||||||
}
|
}
|
||||||
|
|
||||||
const firstImage = fileObjects.find(fo => globals.SupportedImageTypes.includes(Path.extname(fo.file.name).toLowerCase().slice(1)))
|
const firstImage = fileObjects.find((fo) => globals.SupportedImageTypes.includes(Path.extname(fo.file.name).toLowerCase().slice(1)))
|
||||||
if (firstImage?.file?._path) {
|
if (firstImage?.file?._path) {
|
||||||
payload.ebookCoverPath = firstImage.file._path
|
payload.ebookCoverPath = firstImage.file._path
|
||||||
} else {
|
} else {
|
||||||
@ -106,4 +106,4 @@ async function parse(ebookFile) {
|
|||||||
|
|
||||||
return payload
|
return payload
|
||||||
}
|
}
|
||||||
module.exports.parse = parse
|
module.exports.parse = parse
|
||||||
|
Loading…
Reference in New Issue
Block a user