🔩 Tweaking filters
This commit is contained in:
@@ -21,7 +21,7 @@ export const greet = async (
|
|||||||
};
|
};
|
||||||
|
|
||||||
const fileObjects = await walkFolder("./comics");
|
const fileObjects = await walkFolder("./comics");
|
||||||
const extractedDataPromises = _.map(fileObjects, async (fileObject) => {
|
{
|
||||||
if (SUPPORTED_COMIC_ARCHIVES.includes(fileObject.extension)) {
|
if (SUPPORTED_COMIC_ARCHIVES.includes(fileObject.extension)) {
|
||||||
return await extractCoverFromComicBookArchive({
|
return await extractCoverFromComicBookArchive({
|
||||||
...targetOptions,
|
...targetOptions,
|
||||||
@@ -30,7 +30,5 @@ export const greet = async (
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Promise.all(extractedDataPromises).then((data) => {
|
|
||||||
console.log(data);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -149,17 +149,6 @@ export const unrar = async (
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const extractMetadataFromImage = async (
|
|
||||||
imageFilePath: string,
|
|
||||||
): Promise<unknown> => {
|
|
||||||
const image = await sharp(imageFilePath)
|
|
||||||
.metadata()
|
|
||||||
.then(function (metadata) {
|
|
||||||
return metadata;
|
|
||||||
});
|
|
||||||
return image;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const unzip = async (
|
export const unzip = async (
|
||||||
extractionOptions: IExtractionOptions,
|
extractionOptions: IExtractionOptions,
|
||||||
walkedFolder: IFolderData,
|
walkedFolder: IFolderData,
|
||||||
@@ -227,7 +216,7 @@ export const extractArchive = async (
|
|||||||
return {
|
return {
|
||||||
message: "File format not supported, yet.",
|
message: "File format not supported, yet.",
|
||||||
errorCode: "90",
|
errorCode: "90",
|
||||||
data: "asda",
|
data: `${extractionOptions}`,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -255,10 +244,11 @@ export const getCovers = async (
|
|||||||
case "single":
|
case "single":
|
||||||
return await extractArchive(options, walkedFolders[0]);
|
return await extractArchive(options, walkedFolders[0]);
|
||||||
default:
|
default:
|
||||||
|
logger.error("Unknown extraction mode selected.");
|
||||||
return {
|
return {
|
||||||
message: "File format not supported, yet.",
|
message: "Unknown extraction mode selected.",
|
||||||
errorCode: "90",
|
errorCode: "90",
|
||||||
data: "asda",
|
data: `${options}`,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -285,6 +275,9 @@ export const walkFolder = async (folder: string): Promise<IFolderData[]> => {
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const filterNonComicBookExtensions = (entities) => {
|
||||||
|
return entities.filter((entity) => entity.extname)
|
||||||
|
}
|
||||||
export const explodePath = (filePath: string): IExplodedPathResponse => {
|
export const explodePath = (filePath: string): IExplodedPathResponse => {
|
||||||
const exploded = filePath.split("/");
|
const exploded = filePath.split("/");
|
||||||
const fileName = remove(exploded, (item) => {
|
const fileName = remove(exploded, (item) => {
|
||||||
@@ -311,3 +304,14 @@ const constructPaths = (
|
|||||||
walkedFolder.extension,
|
walkedFolder.extension,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const extractMetadataFromImage = async (
|
||||||
|
imageFilePath: string,
|
||||||
|
): Promise<unknown> => {
|
||||||
|
const image = await sharp(imageFilePath)
|
||||||
|
.metadata()
|
||||||
|
.then(function (metadata) {
|
||||||
|
return metadata;
|
||||||
|
});
|
||||||
|
return image;
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user