✏️ Adding the scaffold for full extraction of rar and zips
This commit is contained in:
@@ -42,7 +42,6 @@ const brokerConfig: BrokerOptions = {
|
|||||||
// Enable/disable logging or use custom logger. More info: https://moleculer.services/docs/0.14/logging.html
|
// Enable/disable logging or use custom logger. More info: https://moleculer.services/docs/0.14/logging.html
|
||||||
// Available logger types: "Console", "File", "Pino", "Winston", "Bunyan", "debug", "Log4js", "Datadog"
|
// Available logger types: "Console", "File", "Pino", "Winston", "Bunyan", "debug", "Log4js", "Datadog"
|
||||||
logger: [
|
logger: [
|
||||||
|
|
||||||
{
|
{
|
||||||
type: "Console",
|
type: "Console",
|
||||||
options: {
|
options: {
|
||||||
@@ -81,11 +80,11 @@ const brokerConfig: BrokerOptions = {
|
|||||||
// Default log level for built-in console logger. It can be overwritten in logger options above.
|
// Default log level for built-in console logger. It can be overwritten in logger options above.
|
||||||
// Available values: trace, debug, info, warn, error, fatal
|
// Available values: trace, debug, info, warn, error, fatal
|
||||||
logLevel: {
|
logLevel: {
|
||||||
"TRACING": "trace",
|
TRACING: "trace",
|
||||||
"TRANS*": "warn",
|
"TRANS*": "warn",
|
||||||
"GREETER": "debug",
|
GREETER: "debug",
|
||||||
"**": "info",
|
"**": "info",
|
||||||
},
|
},
|
||||||
|
|
||||||
// Define transporter.
|
// Define transporter.
|
||||||
// More info: https://moleculer.services/docs/0.14/networking.html
|
// More info: https://moleculer.services/docs/0.14/networking.html
|
||||||
@@ -205,7 +204,7 @@ const brokerConfig: BrokerOptions = {
|
|||||||
|
|
||||||
// Enable built-in tracing function. More info: https://moleculer.services/docs/0.14/tracing.html
|
// Enable built-in tracing function. More info: https://moleculer.services/docs/0.14/tracing.html
|
||||||
tracing: {
|
tracing: {
|
||||||
enabled: false,
|
enabled: true,
|
||||||
// Available built-in exporters: "Console", "Datadog", "Event", "EventLegacy", "Jaeger", "Zipkin"
|
// Available built-in exporters: "Console", "Datadog", "Event", "EventLegacy", "Jaeger", "Zipkin"
|
||||||
exporter: {
|
exporter: {
|
||||||
type: "Console", // Console exporter is only for development!
|
type: "Console", // Console exporter is only for development!
|
||||||
|
|||||||
@@ -31,13 +31,7 @@ SOFTWARE.
|
|||||||
* Initial: 2021/05/04 Rishi Ghan
|
* Initial: 2021/05/04 Rishi Ghan
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import { createReadStream, createWriteStream, existsSync } from "fs";
|
||||||
createReadStream, createWriteStream,
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
existsSync
|
|
||||||
} from "fs";
|
|
||||||
import { isEmpty, isNil, isUndefined, remove } from "lodash";
|
import { isEmpty, isNil, isUndefined, remove } from "lodash";
|
||||||
import * as p7zip from "p7zip-threetwo";
|
import * as p7zip from "p7zip-threetwo";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
@@ -199,7 +193,7 @@ export const extractComicInfoXMLFromZip = async (
|
|||||||
({ name }) => !IMPORT_IMAGE_FILE_FORMATS.includes(path.extname(name))
|
({ name }) => !IMPORT_IMAGE_FILE_FORMATS.includes(path.extname(name))
|
||||||
);
|
);
|
||||||
|
|
||||||
// detect comicinfo.xml
|
// detect ComicInfo.xml
|
||||||
const comicInfoXMLFileObject = remove(
|
const comicInfoXMLFileObject = remove(
|
||||||
filesFromArchive.files,
|
filesFromArchive.files,
|
||||||
(file) => path.basename(file.name.toLowerCase()) === "comicinfo.xml"
|
(file) => path.basename(file.name.toLowerCase()) === "comicinfo.xml"
|
||||||
@@ -304,19 +298,16 @@ export const extractComicInfoXMLFromZip = async (
|
|||||||
export const extractFromArchive = async (filePath: string) => {
|
export const extractFromArchive = async (filePath: string) => {
|
||||||
console.info(`Unrar is located at: ${UNRAR_BIN_PATH}`);
|
console.info(`Unrar is located at: ${UNRAR_BIN_PATH}`);
|
||||||
const { extension } = getFileConstituents(filePath);
|
const { extension } = getFileConstituents(filePath);
|
||||||
|
console.log(
|
||||||
|
`Detected file type is ${extension}, looking for comicinfo.xml...`
|
||||||
|
);
|
||||||
switch (extension) {
|
switch (extension) {
|
||||||
case ".cbz":
|
case ".cbz":
|
||||||
case ".cb7":
|
case ".cb7":
|
||||||
console.log(
|
|
||||||
"Detected file type is cbz, looking for comicinfo.xml..."
|
|
||||||
);
|
|
||||||
const cbzResult = await extractComicInfoXMLFromZip(filePath);
|
const cbzResult = await extractComicInfoXMLFromZip(filePath);
|
||||||
return Object.assign({}, ...cbzResult);
|
return Object.assign({}, ...cbzResult);
|
||||||
|
|
||||||
case ".cbr":
|
case ".cbr":
|
||||||
console.log(
|
|
||||||
"Detected file type is cbr, looking for comicinfo.xml..."
|
|
||||||
);
|
|
||||||
const cbrResult = await extractComicInfoXMLFromRar(filePath);
|
const cbrResult = await extractComicInfoXMLFromRar(filePath);
|
||||||
return Object.assign({}, ...cbrResult);
|
return Object.assign({}, ...cbrResult);
|
||||||
|
|
||||||
@@ -327,3 +318,17 @@ export const extractFromArchive = async (filePath: string) => {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const uncompressEntireArchive = async (filePath: string) => {
|
||||||
|
const { extension } = getFileConstituents(filePath);
|
||||||
|
switch (extension) {
|
||||||
|
case ".cbz":
|
||||||
|
case ".cb7":
|
||||||
|
return await uncompressZipArchive(filePath);
|
||||||
|
case ".cbr":
|
||||||
|
return await uncompressRarArchive(filePath);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const uncompressZipArchive = async (filePath: string) => { };
|
||||||
|
export const uncompressRarArchive = async (filePath: string) => { };
|
||||||
|
|||||||
Reference in New Issue
Block a user