From 89a0fc709015a43c4c3deb0d18376c05dd5f4395 Mon Sep 17 00:00:00 2001 From: Rishi Ghan Date: Tue, 15 Mar 2022 02:04:11 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Implemented=20the=20long-awaited?= =?UTF-8?q?=20refactor=20of=20the=20unzip=20and=20unrar=20methods=20for=20?= =?UTF-8?q?cover=20and=20metadata=20extraction?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/comic.model.ts | 6 +- models/comicinfoXML.model.ts | 6 + package-lock.json | 303 +++++++++++++++++-------- package.json | 2 +- services/libraryqueue.service.ts | 113 ++++++---- utils/uncompression.utils.ts | 376 +++++++++++-------------------- yarn.lock | 122 ++++++---- 7 files changed, 505 insertions(+), 423 deletions(-) create mode 100644 models/comicinfoXML.model.ts diff --git a/models/comic.model.ts b/models/comic.model.ts index d1e281f..92a9cef 100644 --- a/models/comic.model.ts +++ b/models/comic.model.ts @@ -57,7 +57,11 @@ const ComicSchema = mongoose.Schema( shortboxed: {}, gcd: {}, }, - rawFileDetails: { type: RawFileDetailsSchema, es_indexed: true, default: {} }, + rawFileDetails: { + type: RawFileDetailsSchema, + es_indexed: true, + default: {}, + }, inferredMetadata: { issue: { name: { type: String, es_indexed: true }, diff --git a/models/comicinfoXML.model.ts b/models/comicinfoXML.model.ts new file mode 100644 index 0000000..fed15ab --- /dev/null +++ b/models/comicinfoXML.model.ts @@ -0,0 +1,6 @@ +const mongoose = require("mongoose"); + +const ComicInfoXMLSchema = mongoose.Schema({ + +}); +export default ComicInfoXMLSchema; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 35b531e..671c771 100644 --- a/package-lock.json +++ b/package-lock.json @@ -43,7 +43,7 @@ "mongoose-elasticsearch-xp": "^5.8.0", "mongoose-paginate-v2": "^1.3.18", "nats": "^1.3.2", - "node-7z": "^3.0.0", + "node-7z-forall": "^2.1.5", "node-calibre": "^2.1.1", "node-unrar-js": "^1.0.5", "sharp": "^0.28.3", @@ -2273,6 +2273,34 @@ "url": "https://github.com/sponsors/epoberezkin" } }, + "node_modules/all-unpacker": { + "version": "0.1.14", + "resolved": "https://registry.npmjs.org/all-unpacker/-/all-unpacker-0.1.14.tgz", + "integrity": "sha512-zRBzpOx1WAlA7hIV/eMN4aS4TsKnj85Y48X3UzU65zhZA3hOJjTdL1JKh52ut6lXXqgv7MjQQXWwSUaduQrXSQ==", + "deprecated": "use node-unar", + "hasInstallScript": true, + "optionalDependencies": { + "fs-extra": "^9.0.1", + "node-stream-zip": "^1.12.0", + "node-wget-fetch": "^1.0.5", + "system-installer": "^1.1.5" + } + }, + "node_modules/all-unpacker/node_modules/fs-extra": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz", + "integrity": "sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==", + "optional": true, + "dependencies": { + "at-least-node": "^1.0.0", + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/ansi-colors": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", @@ -2524,6 +2552,14 @@ "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" }, + "node_modules/at-least-node": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/at-least-node/-/at-least-node-1.0.0.tgz", + "integrity": "sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==", + "engines": { + "node": ">= 4.0.0" + } + }, "node_modules/aws-sign2": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", @@ -3438,7 +3474,6 @@ "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", - "dev": true, "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", @@ -5820,8 +5855,7 @@ "node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", - "dev": true + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" }, "node_modules/isstream": { "version": "0.1.2", @@ -8519,36 +8553,16 @@ "resolved": "https://registry.npmjs.org/lodash.defaults/-/lodash.defaults-4.2.0.tgz", "integrity": "sha1-0JF4cW/+pN3p5ft7N/bwgCJ0WAw=" }, - "node_modules/lodash.defaultsdeep": { - "version": "4.6.1", - "resolved": "https://registry.npmjs.org/lodash.defaultsdeep/-/lodash.defaultsdeep-4.6.1.tgz", - "integrity": "sha512-3j8wdDzYuWO3lM3Reg03MuQR957t287Rpcxp1njpEa8oDrikb+FwGdW3n+FELh/A6qib6yPit0j/pv9G/yeAqA==" - }, - "node_modules/lodash.defaultto": { - "version": "4.14.0", - "resolved": "https://registry.npmjs.org/lodash.defaultto/-/lodash.defaultto-4.14.0.tgz", - "integrity": "sha1-OL09QlrO5zPg4ru9TkspcRzC7hE=" - }, "node_modules/lodash.flatten": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/lodash.flatten/-/lodash.flatten-4.4.0.tgz", "integrity": "sha1-8xwiIlqWMtK7+OSt2+8kCqdlph8=" }, - "node_modules/lodash.flattendeep": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz", - "integrity": "sha1-+wMJF/hqMTTlvJvsDWngAT3f7bI=" - }, "node_modules/lodash.isarguments": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz", "integrity": "sha1-L1c9hcaiQon/AGY7SRwdM4/zRYo=" }, - "node_modules/lodash.isempty": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/lodash.isempty/-/lodash.isempty-4.4.0.tgz", - "integrity": "sha1-b4bL7di+TsmHvpqvM8loTbGzHn4=" - }, "node_modules/lodash.memoize": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", @@ -8561,11 +8575,6 @@ "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", "dev": true }, - "node_modules/lodash.negate": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/lodash.negate/-/lodash.negate-3.0.2.tgz", - "integrity": "sha1-nIl7C/YQAZ4LQ7j/Pwr+89e2bzQ=" - }, "node_modules/lodash.sortby": { "version": "4.7.0", "resolved": "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz", @@ -8683,6 +8692,17 @@ "es5-ext": "~0.10.2" } }, + "node_modules/macos-release": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/macos-release/-/macos-release-2.5.0.tgz", + "integrity": "sha512-EIgv+QZ9r+814gjJj0Bt5vSLJLzswGmSUbUpbi9AIr/fsN2IWFBl2NucV9PAiek+U1STK468tEkxmVYUtuAN3g==", + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/make-dir": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", @@ -9359,18 +9379,34 @@ "integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=", "dev": true }, - "node_modules/node-7z": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/node-7z/-/node-7z-3.0.0.tgz", - "integrity": "sha512-KIznWSxIkOYO/vOgKQfJEaXd7rgoFYKZbaurainCEdMhYc7V7mRHX+qdf2HgbpQFcdJL/Q6/XOPrDLoBeTfuZA==", + "node_modules/node-7z-forall": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/node-7z-forall/-/node-7z-forall-2.1.5.tgz", + "integrity": "sha512-rn5voRDiSMPTIwnCW89lJpnJ2KdMeHSQU/Yraq7WMyVAqSwfJ9FirJhNIO5HVnUBPAh5VI+L76T6T8KjvnNaoQ==", + "deprecated": "use node-7z-archive", + "hasInstallScript": true, "dependencies": { - "debug": "^4.3.2", - "lodash.defaultsdeep": "^4.6.1", - "lodash.defaultto": "^4.14.0", - "lodash.flattendeep": "^4.4.0", - "lodash.isempty": "^4.4.0", - "lodash.negate": "^3.0.2", - "normalize-path": "^3.0.0" + "all-unpacker": "^0.1.14", + "cross-spawn": "^7.0.3", + "fs-extra": "^9.1.0", + "macos-release": "^2.5.0", + "node-wget-fetch": "1.0.5", + "system-installer": "^1.1.6", + "when": "^3.7.8" + }, + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/node-7z-forall/node_modules/fs-extra": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz", + "integrity": "sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==", + "dependencies": { + "at-least-node": "^1.0.0", + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" }, "engines": { "node": ">=10" @@ -9452,6 +9488,19 @@ "integrity": "sha512-CqyzN6z7Q6aMeF/ktcMVTzhAHCEpf8SOarwpzpf8pNBY2k5/oM34UHldUwp8VKI7uxct2HxSRdJjBaZeESzcxA==", "dev": true }, + "node_modules/node-stream-zip": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/node-stream-zip/-/node-stream-zip-1.15.0.tgz", + "integrity": "sha512-LN4fydt9TqhZhThkZIVQnF9cwjU3qmUH9h78Mx/K7d3VvfRqqwthLwJEUOEL0QPZ0XQmNN7be5Ggit5+4dq3Bw==", + "optional": true, + "engines": { + "node": ">=0.12.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/antelle" + } + }, "node_modules/node-unrar-js": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/node-unrar-js/-/node-unrar-js-1.0.5.tgz", @@ -9460,6 +9509,21 @@ "node": ">=10.0.0" } }, + "node_modules/node-wget-fetch": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/node-wget-fetch/-/node-wget-fetch-1.0.5.tgz", + "integrity": "sha512-OIHBPIhtIipSvJFe8a7lZxius6oXA4Au4PschqkDwWvhzBA9lKj2VDVLVI1KtYpSLO2fQxTdn8fljPOiA2CnKw==", + "dependencies": { + "node-fetch": "~2.6.1" + }, + "bin": { + "fetch": "cli.js", + "wget": "cli.js" + }, + "engines": { + "node": ">=10.0.0" + } + }, "node_modules/normalize-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", @@ -12077,6 +12141,8 @@ }, "node_modules/npm/node_modules/which": { "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", "dev": true, "inBundle": true, "license": "ISC", @@ -12561,7 +12627,6 @@ "version": "3.1.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", - "dev": true, "engines": { "node": ">=8" } @@ -13495,7 +13560,6 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", - "dev": true, "dependencies": { "shebang-regex": "^3.0.0" }, @@ -13507,7 +13571,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", - "dev": true, "engines": { "node": ">=8" } @@ -13977,6 +14040,18 @@ "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz", "integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==" }, + "node_modules/system-installer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/system-installer/-/system-installer-1.1.6.tgz", + "integrity": "sha512-Meo6iHB+nVe/K7Bb7XerrZNWj5KkPu0KQwJpvfkZPnKO0kHV/JezTwTNB1T9A71b2ruDXAazME4AMrFqyR6bYA==", + "deprecated": "use node-sys", + "dependencies": { + "which": "^2.0.2" + }, + "bin": { + "system-installer": "cli.js" + } + }, "node_modules/table": { "version": "6.8.0", "resolved": "https://registry.npmjs.org/table/-/table-6.8.0.tgz", @@ -14709,11 +14784,15 @@ "webidl-conversions": "^4.0.2" } }, + "node_modules/when": { + "version": "3.7.8", + "resolved": "https://registry.npmjs.org/when/-/when-3.7.8.tgz", + "integrity": "sha1-xxMLan6gRpPoQs3J56Hyqjmjn4I=" + }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, "dependencies": { "isexe": "^2.0.0" }, @@ -16741,6 +16820,31 @@ "uri-js": "^4.2.2" } }, + "all-unpacker": { + "version": "0.1.14", + "resolved": "https://registry.npmjs.org/all-unpacker/-/all-unpacker-0.1.14.tgz", + "integrity": "sha512-zRBzpOx1WAlA7hIV/eMN4aS4TsKnj85Y48X3UzU65zhZA3hOJjTdL1JKh52ut6lXXqgv7MjQQXWwSUaduQrXSQ==", + "requires": { + "fs-extra": "^9.0.1", + "node-stream-zip": "^1.12.0", + "node-wget-fetch": "^1.0.5", + "system-installer": "^1.1.5" + }, + "dependencies": { + "fs-extra": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz", + "integrity": "sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==", + "optional": true, + "requires": { + "at-least-node": "^1.0.0", + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + } + } + } + }, "ansi-colors": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", @@ -16930,6 +17034,11 @@ "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" }, + "at-least-node": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/at-least-node/-/at-least-node-1.0.0.tgz", + "integrity": "sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==" + }, "aws-sign2": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", @@ -17636,7 +17745,6 @@ "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", - "dev": true, "requires": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", @@ -19436,8 +19544,7 @@ "isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", - "dev": true + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" }, "isstream": { "version": "0.1.2", @@ -21482,36 +21589,16 @@ "resolved": "https://registry.npmjs.org/lodash.defaults/-/lodash.defaults-4.2.0.tgz", "integrity": "sha1-0JF4cW/+pN3p5ft7N/bwgCJ0WAw=" }, - "lodash.defaultsdeep": { - "version": "4.6.1", - "resolved": "https://registry.npmjs.org/lodash.defaultsdeep/-/lodash.defaultsdeep-4.6.1.tgz", - "integrity": "sha512-3j8wdDzYuWO3lM3Reg03MuQR957t287Rpcxp1njpEa8oDrikb+FwGdW3n+FELh/A6qib6yPit0j/pv9G/yeAqA==" - }, - "lodash.defaultto": { - "version": "4.14.0", - "resolved": "https://registry.npmjs.org/lodash.defaultto/-/lodash.defaultto-4.14.0.tgz", - "integrity": "sha1-OL09QlrO5zPg4ru9TkspcRzC7hE=" - }, "lodash.flatten": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/lodash.flatten/-/lodash.flatten-4.4.0.tgz", "integrity": "sha1-8xwiIlqWMtK7+OSt2+8kCqdlph8=" }, - "lodash.flattendeep": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz", - "integrity": "sha1-+wMJF/hqMTTlvJvsDWngAT3f7bI=" - }, "lodash.isarguments": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz", "integrity": "sha1-L1c9hcaiQon/AGY7SRwdM4/zRYo=" }, - "lodash.isempty": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/lodash.isempty/-/lodash.isempty-4.4.0.tgz", - "integrity": "sha1-b4bL7di+TsmHvpqvM8loTbGzHn4=" - }, "lodash.memoize": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", @@ -21524,11 +21611,6 @@ "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", "dev": true }, - "lodash.negate": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/lodash.negate/-/lodash.negate-3.0.2.tgz", - "integrity": "sha1-nIl7C/YQAZ4LQ7j/Pwr+89e2bzQ=" - }, "lodash.sortby": { "version": "4.7.0", "resolved": "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz", @@ -21621,6 +21703,11 @@ "es5-ext": "~0.10.2" } }, + "macos-release": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/macos-release/-/macos-release-2.5.0.tgz", + "integrity": "sha512-EIgv+QZ9r+814gjJj0Bt5vSLJLzswGmSUbUpbi9AIr/fsN2IWFBl2NucV9PAiek+U1STK468tEkxmVYUtuAN3g==" + }, "make-dir": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", @@ -22036,18 +22123,31 @@ "integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=", "dev": true }, - "node-7z": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/node-7z/-/node-7z-3.0.0.tgz", - "integrity": "sha512-KIznWSxIkOYO/vOgKQfJEaXd7rgoFYKZbaurainCEdMhYc7V7mRHX+qdf2HgbpQFcdJL/Q6/XOPrDLoBeTfuZA==", + "node-7z-forall": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/node-7z-forall/-/node-7z-forall-2.1.5.tgz", + "integrity": "sha512-rn5voRDiSMPTIwnCW89lJpnJ2KdMeHSQU/Yraq7WMyVAqSwfJ9FirJhNIO5HVnUBPAh5VI+L76T6T8KjvnNaoQ==", "requires": { - "debug": "^4.3.2", - "lodash.defaultsdeep": "^4.6.1", - "lodash.defaultto": "^4.14.0", - "lodash.flattendeep": "^4.4.0", - "lodash.isempty": "^4.4.0", - "lodash.negate": "^3.0.2", - "normalize-path": "^3.0.0" + "all-unpacker": "^0.1.14", + "cross-spawn": "^7.0.3", + "fs-extra": "^9.1.0", + "macos-release": "^2.5.0", + "node-wget-fetch": "1.0.5", + "system-installer": "^1.1.6", + "when": "^3.7.8" + }, + "dependencies": { + "fs-extra": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz", + "integrity": "sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==", + "requires": { + "at-least-node": "^1.0.0", + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + } + } } }, "node-abi": { @@ -22116,11 +22216,25 @@ "integrity": "sha512-CqyzN6z7Q6aMeF/ktcMVTzhAHCEpf8SOarwpzpf8pNBY2k5/oM34UHldUwp8VKI7uxct2HxSRdJjBaZeESzcxA==", "dev": true }, + "node-stream-zip": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/node-stream-zip/-/node-stream-zip-1.15.0.tgz", + "integrity": "sha512-LN4fydt9TqhZhThkZIVQnF9cwjU3qmUH9h78Mx/K7d3VvfRqqwthLwJEUOEL0QPZ0XQmNN7be5Ggit5+4dq3Bw==", + "optional": true + }, "node-unrar-js": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/node-unrar-js/-/node-unrar-js-1.0.5.tgz", "integrity": "sha512-e2FfnO1rsbXIYPTHkzA/FV8+xDeuEIyRd5X8VQmWJMC5zeZFV9PX1TROTv2bmukX1kBJ2U8Lzu7LZiwUXByaOQ==" }, + "node-wget-fetch": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/node-wget-fetch/-/node-wget-fetch-1.0.5.tgz", + "integrity": "sha512-OIHBPIhtIipSvJFe8a7lZxius6oXA4Au4PschqkDwWvhzBA9lKj2VDVLVI1KtYpSLO2fQxTdn8fljPOiA2CnKw==", + "requires": { + "node-fetch": "~2.6.1" + } + }, "normalize-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", @@ -23981,6 +24095,8 @@ }, "which": { "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", "bundled": true, "dev": true, "requires": { @@ -24343,8 +24459,7 @@ "path-key": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", - "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", - "dev": true + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==" }, "path-parse": { "version": "1.0.7", @@ -25041,7 +25156,6 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", - "dev": true, "requires": { "shebang-regex": "^3.0.0" } @@ -25049,8 +25163,7 @@ "shebang-regex": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", - "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", - "dev": true + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==" }, "side-channel": { "version": "1.0.4", @@ -25405,6 +25518,14 @@ "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz", "integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==" }, + "system-installer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/system-installer/-/system-installer-1.1.6.tgz", + "integrity": "sha512-Meo6iHB+nVe/K7Bb7XerrZNWj5KkPu0KQwJpvfkZPnKO0kHV/JezTwTNB1T9A71b2ruDXAazME4AMrFqyR6bYA==", + "requires": { + "which": "^2.0.2" + } + }, "table": { "version": "6.8.0", "resolved": "https://registry.npmjs.org/table/-/table-6.8.0.tgz", @@ -26001,11 +26122,15 @@ "webidl-conversions": "^4.0.2" } }, + "when": { + "version": "3.7.8", + "resolved": "https://registry.npmjs.org/when/-/when-3.7.8.tgz", + "integrity": "sha1-xxMLan6gRpPoQs3J56Hyqjmjn4I=" + }, "which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, "requires": { "isexe": "^2.0.0" } diff --git a/package.json b/package.json index 7ba543d..5086804 100644 --- a/package.json +++ b/package.json @@ -74,7 +74,7 @@ "mongoose-elasticsearch-xp": "^5.8.0", "mongoose-paginate-v2": "^1.3.18", "nats": "^1.3.2", - "node-7z": "^3.0.0", + "node-7z-forall": "^2.1.5", "node-calibre": "^2.1.1", "node-unrar-js": "^1.0.5", "sharp": "^0.28.3", diff --git a/services/libraryqueue.service.ts b/services/libraryqueue.service.ts index 4feb50f..0a40f19 100644 --- a/services/libraryqueue.service.ts +++ b/services/libraryqueue.service.ts @@ -46,11 +46,12 @@ import BullMQMixin from "moleculer-bull"; import { SandboxedJob } from "moleculer-bull"; import { DbMixin } from "../mixins/db.mixin"; import Comic from "../models/comic.model"; -import { extractFromArchive, extractCoverFromFile2 } from "../utils/uncompression.utils"; +import { extractFromArchive } from "../utils/uncompression.utils"; import { refineQuery } from "filename-parser"; import { io } from "./api.service"; import { getFileConstituents } from "../utils/file.utils"; import { USERDATA_DIRECTORY } from "../constants/directories"; +import { IExtractedComicBookCoverFile } from "threetwo-ui-typings"; const REDIS_URI = process.env.REDIS_URI || `redis://0.0.0.0:6379`; console.log(`REDIS -> ${REDIS_URI}`); @@ -69,58 +70,75 @@ export default class QueueService extends Service { console.info("New job received!", job.data); console.info(`Processing queue...`); // extract the cover - // const result = await extractCoverFromFile2( - // job.data.fileObject - // ); - const { + const result = await extractFromArchive( + job.data.fileObject.filePath + ); + Object.assign(result, { + fileSize: job.data.fileObject.fileSize, + }); + console.log("KEYSS TO THE KINGDOM:", result) + const { + name, + filePath, + fileSize, extension, - fileNameWithExtension, - fileNameWithoutExtension, - } = getFileConstituents(job.data.fileObject.filePath); - const targetDirectory = `${USERDATA_DIRECTORY}/covers/${fileNameWithoutExtension}`; - const foo = await extractFromArchive(job.data.fileObject.filePath, targetDirectory, extension ); - console.log("JAADASD!@#!@#@!", foo); + cover, + containedIn, + comicInfoJSON, + } = result; - // infer any issue-related metadata from the filename - // const { inferredIssueDetails } = refineQuery(result.name); - // console.log("Issue metadata inferred: ", JSON.stringify(inferredIssueDetails, null, 2)); - - // // // write to mongo - // console.log("Writing to mongo...") - // const dbImportResult = await this.broker.call( - // "library.rawImportToDB", - // { - // importStatus: { - // isImported: true, - // tagged: false, - // matchedResult: { - // score: "0", - // }, - // }, - // rawFileDetails: result, - // inferredMetadata: { - // issue: inferredIssueDetails, - // }, - // sourcedMetadata: { - // comicInfo: {}, - // comicvine: {}, - // }, - // // since we already have at least 1 copy - // // mark it as not wanted by default - // acquisition: { - // wanted: false, - // } - // } - // ); + // Infer any issue-related metadata from the filename + const { inferredIssueDetails } = refineQuery( + result.name + ); + + console.log( + "Issue metadata inferred: ", + JSON.stringify(inferredIssueDetails, null, 2) + ); + + // write to mongo + console.log("Writing to mongo..."); + const dbImportResult = await this.broker.call( + "library.rawImportToDB", + { + importStatus: { + isImported: true, + tagged: false, + matchedResult: { + score: "0", + }, + }, + rawFileDetails: { + name, + filePath, + fileSize, + extension, + containedIn, + cover, + }, + inferredMetadata: { + issue: inferredIssueDetails, + }, + sourcedMetadata: { + comicInfo: comicInfoJSON, + comicvine: {}, + }, + // since we already have at least 1 copy + // mark it as not wanted by default + acquisition: { + wanted: false, + }, + } + ); return Promise.resolve({ - // dbImportResult, + dbImportResult, id: job.id, worker: process.pid, }); }, }, - }, actions: { processImport: { @@ -139,11 +157,8 @@ export default class QueueService extends Service { unarchiveComicBook: { rest: "POST /unarchiveComicBook", params: {}, - handler: async (ctx:Context<{}>) => { - - }, + handler: async (ctx: Context<{}>) => {}, }, - }, methods: {}, async started(): Promise { @@ -176,7 +191,7 @@ export default class QueueService extends Service { `The job with the id '${job.id} got stalled!` ); console.log(`${JSON.stringify(job, null, 2)}`); - console.log(`is stalled.`) + console.log(`is stalled.`); } ); }); diff --git a/utils/uncompression.utils.ts b/utils/uncompression.utils.ts index 48e3539..2828b5d 100644 --- a/utils/uncompression.utils.ts +++ b/utils/uncompression.utils.ts @@ -31,130 +31,45 @@ SOFTWARE. * Initial: 2021/05/04 Rishi Ghan */ -import { createWriteStream, createReadStream, promises as fs } from "fs"; +import { + createWriteStream, + createReadStream, + promises as fs, + readFileSync, +} from "fs"; const fse = require("fs-extra"); const Unrar = require("unrar"); import path, { parse } from "path"; - -import { - IExtractComicBookCoverErrorResponse, - IExtractedComicBookCoverFile, - IExtractionOptions, - IFolderData, - ISharpResizedImageStats, -} from "threetwo-ui-typings"; +import { list, extract, onlyArchive } from "node-7z-forall"; +import { IExtractedComicBookCoverFile } from "threetwo-ui-typings"; import sharp from "sharp"; -import { - explodePath, - getFileConstituents, - walkFolder, -} from "../utils/file.utils"; -import { resizeImage } from "./imagetransformation.utils"; +import { getFileConstituents } from "../utils/file.utils"; import { isNil, isUndefined, remove } from "lodash"; import { convertXMLToJSON } from "./xml.utils"; -import sevenBin from "7zip-bin"; -import { extract, list } from "node-7z"; -const pathTo7zip = sevenBin.path7za; -const { Calibre } = require("node-calibre"); import { USERDATA_DIRECTORY, COMICS_DIRECTORY } from "../constants/directories"; -export const extractCoverFromFile2 = async ( - fileObject: any -): Promise => { - try { - const { filePath, fileSize } = fileObject; - - const calibre = new Calibre(); - console.info(`Initiating extraction process for path ${filePath}`); - - // 1. Check for process.env.COMICS_DIRECTORY and process.env.USERDATA_DIRECTORY - if (!isNil(USERDATA_DIRECTORY)) { - // 2. Create the directory to which the cover image will be extracted - console.info( - "Attempting to create target directory for cover extraction..." - ); - const directoryOptions = { - mode: 0o2775, - }; - const { - extension, - fileNameWithExtension, - fileNameWithoutExtension, - } = getFileConstituents(filePath); - - const targetDirectory = `${USERDATA_DIRECTORY}/covers/${fileNameWithoutExtension}`; - - await fse.ensureDir(targetDirectory, directoryOptions); - console.info(`%s was created.`, targetDirectory); - - // 3. extract the cover - console.info(`Starting cover extraction...`); - let result: string; - const targetCoverImageFilePath = path.resolve( - targetDirectory + "/" + fileNameWithoutExtension + "_cover.jpg" - ); - const ebookMetaPath = process.env.CALIBRE_EBOOK_META_PATH - ? `${process.env.CALIBRE_EBOOK_META_PATH}` - : `ebook-meta`; - result = await calibre.run(ebookMetaPath, [filePath], { - getCover: targetCoverImageFilePath, - }); - console.info( - `ebook-meta ran with the following result: %o`, - result - ); - - // 4. create rendition path - const renditionPath = - targetDirectory + "/" + fileNameWithoutExtension + "_275px.jpg"; - - // 5. resize image - await resizeImage( - targetCoverImageFilePath, - path.resolve(renditionPath), - 275 - ); - return { - name: fileNameWithoutExtension, - filePath, - fileSize, - extension, - cover: { - filePath: path.relative(process.cwd(), renditionPath), - }, - containedIn: path.resolve(fileNameWithExtension), - calibreMetadata: { - coverWriteResult: result, - }, - }; - } - } catch (error) { - console.error(error); - } -}; - export const extractComicInfoXMLFromRar = async ( - filePath: string, - fileToExtract: string -) => { + filePath: string +): Promise> => { const result = { filePath, }; + // Create the target directory const directoryOptions = { mode: 0o2775, }; - const { fileNameWithoutExtension, extension, fileNameWithExtension } = + const { fileNameWithoutExtension, extension } = getFileConstituents(filePath); const targetDirectory = `${USERDATA_DIRECTORY}/covers/${fileNameWithoutExtension}`; await fse.ensureDir(targetDirectory, directoryOptions); console.info(`%s was created.`, targetDirectory); - - const archive = new Unrar({ - path: path.resolve(filePath), - bin: `/usr/local/bin/unrar`, // this will change depending on Docker base OS - }); return new Promise((resolve, reject) => { + const archive = new Unrar({ + path: path.resolve(filePath), + bin: `/usr/local/bin/unrar`, // this will change depending on Docker base OS + }); + archive.list(async (err, entries) => { remove(entries, ({ type }) => type === "Directory"); const comicInfoXML = remove( @@ -168,121 +83,105 @@ export const extractComicInfoXMLFromRar = async ( .localeCompare(b.name.toLowerCase()); } }); - // Cover image extraction and resizing - const sharpStream = sharp().resize(275); - let comicInfoString = ""; - archive - .stream(files[0].name) - .on("error", console.error) - .pipe(sharpStream) - .toFile(`${targetDirectory}/${files[0].name}`, (err, info) => { - if (err) { - console.log("Failed to resize image:"); - console.log(err); - reject(err); - } - console.log( - "Image file resized with the following parameters: %o", - info - ); - // orchestrate result - Object.assign(result, { - name: fileNameWithoutExtension, - extension, - containedIn: targetDirectory, - cover: { - filePath: path.relative( - process.cwd(), - `${targetDirectory}/${files[0].name}` - ), - }, - }); - resolve(result); - }); - // ComicInfo.xml extraction and parsing to JSON - if (!isUndefined(comicInfoXML[0])) { - const comicinfoStream = archive.stream(comicInfoXML[0]["name"]); - comicinfoStream.on("error", console.error); - comicinfoStream.pipe( - createWriteStream( - `${targetDirectory}/${comicInfoXML[0]["name"]}` - ) + const filesToWriteToDisk = [files[0].name, comicInfoXML[0]["name"]]; + remove(filesToWriteToDisk, (file) => !isNil(file.name)); + + if (!isUndefined(comicInfoXML[0]["name"])) { + let comicinfostring = ""; + const writeStream = createWriteStream( + `${targetDirectory}/${comicInfoXML[0]["name"]}` ); - comicinfoStream.on("data", (data) => { - comicInfoString += data; - }); - comicinfoStream.on("end", async () => { - const comicInfoJSON = await convertXMLToJSON( - comicInfoString + + await archive.stream(comicInfoXML[0]["name"]).pipe(writeStream); + writeStream.on("finish", async () => { + const readStream = createReadStream( + `${targetDirectory}/${comicInfoXML[0]["name"]}` ); - console.log(comicInfoJSON); - Object.assign(result, { comicInfo: comicInfoJSON }); + readStream.on("data", (data) => { + comicinfostring += data; + }); + readStream.on("error", (error) => reject(error)); + readStream.on("end", async () => { + const comicInfoJSON = await convertXMLToJSON( + comicinfostring.toString() + ); + Object.assign(result, { + comicInfoJSON: comicInfoJSON.comicinfo, + }); + }); }); } + + const sharpStream = sharp().resize(275); + const coverExtractionStream = archive.stream(files[0].name); + await coverExtractionStream + .pipe(sharpStream) + .toFile(`${targetDirectory}/${files[0].name}`); + // orchestrate result + Object.assign(result, { + name: fileNameWithoutExtension, + extension, + containedIn: targetDirectory, + cover: { + filePath: path.relative( + process.cwd(), + `${targetDirectory}/${files[0].name}` + ), + }, + }); + resolve(result); }); }); }; export const extractComicInfoXMLFromZip = async ( - filePath: string, - outputDirectory: string -) => { + filePath: string +): Promise> => { const result = { filePath, }; - return new Promise((resolve, reject) => { - const fileList = []; - const listStream = list(path.resolve(filePath), { - $bin: pathTo7zip, - }); - listStream.on("data", (chunk) => fileList.push(chunk)); - listStream.on("end", async () => { - // Remove dotfiles and directories - remove( - fileList, - (item) => - item.attributes === "D...." || - !isNil(item.file.match(/(?:^|[\\\/])(\.(?!\.)[^\\\/]+)$/g)) + // Create the target directory + const directoryOptions = { + mode: 0o2775, + }; + const { fileNameWithoutExtension, extension } = + getFileConstituents(filePath); + const targetDirectory = `${USERDATA_DIRECTORY}/covers/${fileNameWithoutExtension}`; + await fse.ensureDir(targetDirectory, directoryOptions); + console.info(`%s was created.`, targetDirectory); + let sortedFiles = []; + const filesToWriteToDisk = []; + return await list(filePath) + .progress((files) => { + // Do stuff with files... + sortedFiles = files.sort((a, b) => { + if (!isUndefined(a) && !isUndefined(b)) { + return a.name + .toLowerCase() + .localeCompare(b.name.toLowerCase()); + } + }); + const comicInfoXML = remove( + sortedFiles, + (file) => file.name.toLowerCase() === "comicinfo.xml" ); - // Look for ComicInfo.xml, if present, - // a. remove it from the fileList - const comicInfoXML = remove(fileList, (item) => - !isUndefined(item) - ? path.basename(item.file).toLowerCase() === "comicinfo.xml" - : undefined - ); - // Sort the file list array naturally - const sortedFileList = fileList.sort((a, b) => - a.file.toLowerCase().localeCompare(b.file.toLowerCase()) - ); - - // Create the target directory - const directoryOptions = { - mode: 0o2775, - }; - const { - fileNameWithoutExtension, - extension, - fileNameWithExtension, - } = getFileConstituents(filePath); - const targetDirectory = `${USERDATA_DIRECTORY}/covers/${fileNameWithoutExtension}`; - await fse.ensureDir(targetDirectory, directoryOptions); - console.info(`%s was created.`, targetDirectory); - - if ( - !isUndefined(sortedFileList[0]) && - !isUndefined(sortedFileList[0].file) - ) { - const coverFileExtractionStream = extract( - `${path.resolve(filePath)}`, - targetDirectory, - { - $cherryPick: [sortedFileList[0].file], - $bin: pathTo7zip, - } - ); - coverFileExtractionStream.on("error", (error) => reject(error)); - coverFileExtractionStream.on("end", (data) => { + if (!isUndefined(comicInfoXML)) { + filesToWriteToDisk.push(comicInfoXML[0].name); + } + filesToWriteToDisk.push(sortedFiles[0].name); + }) + .then((d) => { + return extract(path.resolve(filePath), targetDirectory, { + r: true, + raw: [...filesToWriteToDisk], + }) + .progress((files) => { + console.log(files); + }) + .then(() => { + const coverFile = filesToWriteToDisk.find( + (file) => file.toLowerCase() !== "comicinfo.xml" + ); Object.assign(result, { name: fileNameWithoutExtension, extension, @@ -290,58 +189,57 @@ export const extractComicInfoXMLFromZip = async ( cover: { filePath: path.relative( process.cwd(), - `${targetDirectory}/${sortedFileList[0].file}` + `${targetDirectory}/${coverFile}` ), }, }); - resolve(result); - }); - } - // b. if ComicInfo.xml present, include it in the file list to be written to disk - if (!isUndefined(comicInfoXML[0])) { - console.log(`ComicInfo.xml detected in ${filePath}`); - const comicInfoExtractionStream = extract( - `${path.resolve(filePath)}`, - targetDirectory, - { - $cherryPick: [comicInfoXML[0].file], - $bin: pathTo7zip, - } - ); - comicInfoExtractionStream.on("error", (error) => reject(error)); - comicInfoExtractionStream.on("end", async (data) => { - console.log(`${comicInfoXML[0].file} was extracted.`); - const xml = await fs.readFile( - `${targetDirectory}/${comicInfoXML[0].file}` + // ComicInfoXML detection, parsing and conversion to JSON + let comicinfostring = ""; + const comicInfoFile = filesToWriteToDisk.find( + (file) => file.toLowerCase() === "comicinfo.xml" ); - const comicInfoJSON = await convertXMLToJSON( - xml.toString() - ); - Object.assign(result, { comicInfo: comicInfoJSON }); - resolve(result); + return new Promise((resolve, reject) => { + const comicInfoXMLStream = createReadStream( + `${targetDirectory}/${comicInfoFile}` + ); + comicInfoXMLStream.on("data", (data) => { + comicinfostring += data; + }); + comicInfoXMLStream.on("error", (error) => + console.log(error) + ); + comicInfoXMLStream.on("end", async () => { + const comicInfoJSON = await convertXMLToJSON( + comicinfostring.toString() + ); + Object.assign(result, { + comicInfoJSON: comicInfoJSON.comicinfo, + }); + + resolve(result); + }); + }); + }) + .catch((error) => { + console.log(error); }); - } }); - }); }; -export const extractFromArchive = async ( - filePath: string, - outputDirectory: string, - extension: string -) => { +export const extractFromArchive = async (filePath: string) => { + const { extension } = getFileConstituents(filePath); switch (extension) { case ".cbz": console.log( "Detected file type is cbz, looking for comicinfo.xml..." ); - return await extractComicInfoXMLFromZip(filePath, outputDirectory); + return await extractComicInfoXMLFromZip(filePath); case ".cbr": console.log( "Detected file type is cbr, looking for comicinfo.xml..." ); - return await extractComicInfoXMLFromRar(filePath, outputDirectory); + return await extractComicInfoXMLFromRar(filePath); default: console.log( diff --git a/yarn.lock b/yarn.lock index aa44a40..3629674 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1231,6 +1231,16 @@ "require-from-string" "^2.0.2" "uri-js" "^4.2.2" +"all-unpacker@^0.1.14": + "integrity" "sha512-zRBzpOx1WAlA7hIV/eMN4aS4TsKnj85Y48X3UzU65zhZA3hOJjTdL1JKh52ut6lXXqgv7MjQQXWwSUaduQrXSQ==" + "resolved" "https://registry.npmjs.org/all-unpacker/-/all-unpacker-0.1.14.tgz" + "version" "0.1.14" + optionalDependencies: + "fs-extra" "^9.0.1" + "node-stream-zip" "^1.12.0" + "node-wget-fetch" "^1.0.5" + "system-installer" "^1.1.5" + "ansi-colors@^4.1.1": "integrity" "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==" "resolved" "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz" @@ -1406,6 +1416,11 @@ "resolved" "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz" "version" "0.4.0" +"at-least-node@^1.0.0": + "integrity" "sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==" + "resolved" "https://registry.npmjs.org/at-least-node/-/at-least-node-1.0.0.tgz" + "version" "1.0.0" + "aws-sign2@~0.7.0": "integrity" "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=" "resolved" "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz" @@ -2203,7 +2218,7 @@ dependencies: "ms" "^2.1.1" -"debug@^4.0.0", "debug@^4.0.1", "debug@^4.1.0", "debug@^4.1.1", "debug@^4.3.1", "debug@^4.3.2", "debug@^4.3.3", "debug@~4.3.1", "debug@~4.3.2", "debug@4": +"debug@^4.0.0", "debug@^4.0.1", "debug@^4.1.0", "debug@^4.1.1", "debug@^4.3.1", "debug@^4.3.3", "debug@~4.3.1", "debug@~4.3.2", "debug@4": "integrity" "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==" "resolved" "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz" "version" "4.3.3" @@ -3063,6 +3078,26 @@ "jsonfile" "^6.0.1" "universalify" "^2.0.0" +"fs-extra@^9.0.1": + "integrity" "sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==" + "resolved" "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz" + "version" "9.1.0" + dependencies: + "at-least-node" "^1.0.0" + "graceful-fs" "^4.2.0" + "jsonfile" "^6.0.1" + "universalify" "^2.0.0" + +"fs-extra@^9.1.0": + "integrity" "sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==" + "resolved" "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz" + "version" "9.1.0" + dependencies: + "at-least-node" "^1.0.0" + "graceful-fs" "^4.2.0" + "jsonfile" "^6.0.1" + "universalify" "^2.0.0" + "fs-minipass@^2.0.0", "fs-minipass@^2.1.0": "version" "2.1.0" dependencies: @@ -4612,36 +4647,16 @@ "resolved" "https://registry.npmjs.org/lodash.defaults/-/lodash.defaults-4.2.0.tgz" "version" "4.2.0" -"lodash.defaultsdeep@^4.6.1": - "integrity" "sha512-3j8wdDzYuWO3lM3Reg03MuQR957t287Rpcxp1njpEa8oDrikb+FwGdW3n+FELh/A6qib6yPit0j/pv9G/yeAqA==" - "resolved" "https://registry.npmjs.org/lodash.defaultsdeep/-/lodash.defaultsdeep-4.6.1.tgz" - "version" "4.6.1" - -"lodash.defaultto@^4.14.0": - "integrity" "sha1-OL09QlrO5zPg4ru9TkspcRzC7hE=" - "resolved" "https://registry.npmjs.org/lodash.defaultto/-/lodash.defaultto-4.14.0.tgz" - "version" "4.14.0" - "lodash.flatten@^4.4.0": "integrity" "sha1-8xwiIlqWMtK7+OSt2+8kCqdlph8=" "resolved" "https://registry.npmjs.org/lodash.flatten/-/lodash.flatten-4.4.0.tgz" "version" "4.4.0" -"lodash.flattendeep@^4.4.0": - "integrity" "sha1-+wMJF/hqMTTlvJvsDWngAT3f7bI=" - "resolved" "https://registry.npmjs.org/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz" - "version" "4.4.0" - "lodash.isarguments@^3.1.0": "integrity" "sha1-L1c9hcaiQon/AGY7SRwdM4/zRYo=" "resolved" "https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz" "version" "3.1.0" -"lodash.isempty@^4.4.0": - "integrity" "sha1-b4bL7di+TsmHvpqvM8loTbGzHn4=" - "resolved" "https://registry.npmjs.org/lodash.isempty/-/lodash.isempty-4.4.0.tgz" - "version" "4.4.0" - "lodash.memoize@4.x": "integrity" "sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4=" "resolved" "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz" @@ -4652,11 +4667,6 @@ "resolved" "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz" "version" "4.6.2" -"lodash.negate@^3.0.2": - "integrity" "sha1-nIl7C/YQAZ4LQ7j/Pwr+89e2bzQ=" - "resolved" "https://registry.npmjs.org/lodash.negate/-/lodash.negate-3.0.2.tgz" - "version" "3.0.2" - "lodash.sortby@^4.7.0": "integrity" "sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=" "resolved" "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz" @@ -4702,6 +4712,11 @@ dependencies: "es5-ext" "~0.10.2" +"macos-release@^2.5.0": + "integrity" "sha512-EIgv+QZ9r+814gjJj0Bt5vSLJLzswGmSUbUpbi9AIr/fsN2IWFBl2NucV9PAiek+U1STK468tEkxmVYUtuAN3g==" + "resolved" "https://registry.npmjs.org/macos-release/-/macos-release-2.5.0.tgz" + "version" "2.5.0" + "make-dir@^3.0.0": "integrity" "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==" "resolved" "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz" @@ -5148,18 +5163,18 @@ "resolved" "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz" "version" "1.0.0" -"node-7z@^3.0.0": - "integrity" "sha512-KIznWSxIkOYO/vOgKQfJEaXd7rgoFYKZbaurainCEdMhYc7V7mRHX+qdf2HgbpQFcdJL/Q6/XOPrDLoBeTfuZA==" - "resolved" "https://registry.npmjs.org/node-7z/-/node-7z-3.0.0.tgz" - "version" "3.0.0" +"node-7z-forall@^2.1.5": + "integrity" "sha512-rn5voRDiSMPTIwnCW89lJpnJ2KdMeHSQU/Yraq7WMyVAqSwfJ9FirJhNIO5HVnUBPAh5VI+L76T6T8KjvnNaoQ==" + "resolved" "https://registry.npmjs.org/node-7z-forall/-/node-7z-forall-2.1.5.tgz" + "version" "2.1.5" dependencies: - "debug" "^4.3.2" - "lodash.defaultsdeep" "^4.6.1" - "lodash.defaultto" "^4.14.0" - "lodash.flattendeep" "^4.4.0" - "lodash.isempty" "^4.4.0" - "lodash.negate" "^3.0.2" - "normalize-path" "^3.0.0" + "all-unpacker" "^0.1.14" + "cross-spawn" "^7.0.3" + "fs-extra" "^9.1.0" + "macos-release" "^2.5.0" + "node-wget-fetch" "1.0.5" + "system-installer" "^1.1.6" + "when" "^3.7.8" "node-abi@^2.21.0": "integrity" "sha512-/2D0wOQPgaUWzVSVgRMx+trKJRC2UG4SUc4oCJoXx9Uxjtp0Vy3/kt7zcbxHF8+Z/pK3UloLWzBISg72brfy1w==" @@ -5178,7 +5193,7 @@ "resolved" "https://registry.npmjs.org/node-calibre/-/node-calibre-2.1.1.tgz" "version" "2.1.1" -"node-fetch@^2.6.1": +"node-fetch@^2.6.1", "node-fetch@~2.6.1": "integrity" "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==" "resolved" "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz" "version" "2.6.7" @@ -5209,11 +5224,23 @@ "resolved" "https://registry.npmjs.org/node-releases/-/node-releases-2.0.1.tgz" "version" "2.0.1" +"node-stream-zip@^1.12.0": + "integrity" "sha512-LN4fydt9TqhZhThkZIVQnF9cwjU3qmUH9h78Mx/K7d3VvfRqqwthLwJEUOEL0QPZ0XQmNN7be5Ggit5+4dq3Bw==" + "resolved" "https://registry.npmjs.org/node-stream-zip/-/node-stream-zip-1.15.0.tgz" + "version" "1.15.0" + "node-unrar-js@^1.0.5": "integrity" "sha512-e2FfnO1rsbXIYPTHkzA/FV8+xDeuEIyRd5X8VQmWJMC5zeZFV9PX1TROTv2bmukX1kBJ2U8Lzu7LZiwUXByaOQ==" "resolved" "https://registry.npmjs.org/node-unrar-js/-/node-unrar-js-1.0.5.tgz" "version" "1.0.5" +"node-wget-fetch@^1.0.5", "node-wget-fetch@1.0.5": + "integrity" "sha512-OIHBPIhtIipSvJFe8a7lZxius6oXA4Au4PschqkDwWvhzBA9lKj2VDVLVI1KtYpSLO2fQxTdn8fljPOiA2CnKw==" + "resolved" "https://registry.npmjs.org/node-wget-fetch/-/node-wget-fetch-1.0.5.tgz" + "version" "1.0.5" + dependencies: + "node-fetch" "~2.6.1" + "nopt@*", "nopt@^5.0.0": "version" "5.0.0" dependencies: @@ -6673,6 +6700,13 @@ "resolved" "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz" "version" "3.2.4" +"system-installer@^1.1.5", "system-installer@^1.1.6": + "integrity" "sha512-Meo6iHB+nVe/K7Bb7XerrZNWj5KkPu0KQwJpvfkZPnKO0kHV/JezTwTNB1T9A71b2ruDXAazME4AMrFqyR6bYA==" + "resolved" "https://registry.npmjs.org/system-installer/-/system-installer-1.1.6.tgz" + "version" "1.1.6" + dependencies: + "which" "^2.0.2" + "table@^6.0.9", "table@^6.8.0": "integrity" "sha512-s/fitrbVeEyHKFa7mFdkuQMWlH1Wgw/yEXMt5xACT4ZpzWFluehAxRtUUQKPuWhaLAWhFcVx6w3oC8VKaUfPGA==" "resolved" "https://registry.npmjs.org/table/-/table-6.8.0.tgz" @@ -7246,6 +7280,11 @@ "tr46" "^2.1.0" "webidl-conversions" "^6.1.0" +"when@^3.7.8": + "integrity" "sha1-xxMLan6gRpPoQs3J56Hyqjmjn4I=" + "resolved" "https://registry.npmjs.org/when/-/when-3.7.8.tgz" + "version" "3.7.8" + "which-boxed-primitive@^1.0.2": "integrity" "sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg==" "resolved" "https://registry.npmjs.org/which-boxed-primitive/-/which-boxed-primitive-1.0.2.tgz" @@ -7257,12 +7296,7 @@ "is-string" "^1.0.5" "is-symbol" "^1.0.3" -"which@*", "which@^2.0.2": - "version" "2.0.2" - dependencies: - "isexe" "^2.0.0" - -"which@^2.0.1": +"which@*", "which@^2.0.1", "which@^2.0.2": "integrity" "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==" "resolved" "https://registry.npmjs.org/which/-/which-2.0.2.tgz" "version" "2.0.2"