🎉 ebook-meta for --get-cover works like a dream

This commit is contained in:
2021-07-27 22:01:26 -07:00
parent 3e92bb081a
commit fcb922d52b

View File

@@ -70,7 +70,6 @@ export const extractCoverFromFile = async (
return new Promise(async (resolve, reject) => { return new Promise(async (resolve, reject) => {
try { try {
const constructedPaths = constructPaths(extractionOptions, walkedFolder); const constructedPaths = constructPaths(extractionOptions, walkedFolder);
console.log(constructedPaths);
const calibre = new Calibre({ const calibre = new Calibre({
library: path.resolve("./userdata/calibre-lib"), library: path.resolve("./userdata/calibre-lib"),
}); });
@@ -86,19 +85,25 @@ export const extractCoverFromFile = async (
logger.error(`${error}: Couldn't create directory.`); logger.error(`${error}: Couldn't create directory.`);
} }
let result: string; let result: string;
const targetCoverImageFilePath = path.resolve(constructedPaths.targetPath + "/" + walkedFolder.name + "_cover.jpg")
result = await calibre.run( result = await calibre.run(
"ebook-meta", "ebook-meta",
[path.resolve(constructedPaths.inputFilePath)], [path.resolve(constructedPaths.inputFilePath)],
{ {
getCover: path.resolve(constructedPaths.targetPath + "/cover.jpg"), getCover: targetCoverImageFilePath,
} }
); );
console.log("AJSDASDLASDASDASLK!@#!@#!@#!#@#!@#!@", result); // create renditions
const renditionPath = constructedPaths.targetPath + "/" + walkedFolder.name + "_200px.jpg";
await resizeImage(targetCoverImageFilePath, path.resolve(renditionPath), 200);
resolve({ resolve({
name: "cover.jpg", name: walkedFolder.name,
path: constructedPaths.targetPath, path: constructedPaths.targetPath + "/" + walkedFolder.name + "_200px.jpg", //renditionPath
fileSize: 0, fileSize: 0,
containedIn: walkedFolder.containedIn, containedIn: walkedFolder.containedIn,
//originalPath:
//extension:
}); });
} catch (error) { } catch (error) {
console.log(error); console.log(error);