🤼‍♀️ Support for CV match

This commit is contained in:
2021-08-06 13:44:00 -07:00
parent cf65b36157
commit 9a311d707f
4 changed files with 39 additions and 26 deletions

View File

@@ -12,23 +12,23 @@ const ComicSchema = mongoose.Schema({
userAddedMetadata: {
tags: [],
},
comicInfo: {
blackAndWhite: String,
characters: [String],
count: String,
genre: String,
manga: String,
month: String,
number: String,
pageCount: String,
pages: [],
publisher: String,
summary: String,
title: String,
writer: String,
year: String,
},
sourcedMetadata: {
comicInfo: {
blackAndWhite: String,
characters: [String],
count: String,
genre: String,
manga: String,
month: String,
number: String,
pageCount: String,
pages: [],
publisher: String,
summary: String,
title: String,
writer: String,
year: String,
},
comicvine: {},
shortboxed: {},
gcd: {},

View File

@@ -14,7 +14,6 @@ export default class ApiService extends Service {
// More info about settings: https://moleculer.services/docs/0.14/moleculer-web.html
settings: {
port: process.env.PORT || 3000,
routes: [
{
path: "/api",
@@ -39,7 +38,6 @@ export default class ApiService extends Service {
use: [],
mergeParams: true,
autoAliases: true,
aliases: {},
// Calling options. More info: https://moleculer.services/docs/0.14/moleculer-web.html#Calling-options
@@ -55,11 +53,7 @@ export default class ApiService extends Service {
limit: "1MB",
},
},
// Mapping policy setting. More info: https://moleculer.services/docs/0.14/moleculer-web.html#Mapping-policy
mappingPolicy: "all", // Available values: "all", "restrict"
// Enable/disable logging
logging: true,
},
{
@@ -71,15 +65,11 @@ export default class ApiService extends Service {
use: [ApiGateway.serveStatic("comics")],
},
],
// Do not log client side errors (does not log an error response when the error.code is 400<=X<500)
log4XXResponses: false,
// Logging the request parameters. Set to any log level to enable it. E.g. "info"
logRequestParams: null,
// Logging the response data. Set to any log level to enable it. E.g. "info"
logResponseData: null,
assets: {
folder: "public",
// Options to `server-static` module
options: {},
},
},

View File

@@ -10,6 +10,7 @@ import { DbMixin } from "../mixins/db.mixin";
import Comic from "../models/comic.model";
import { walkFolder } from "../utils/file.utils";
import { convertXMLToJSON } from "../utils/xml.utils";
const ObjectId = require("mongoose").Types.ObjectId;
export default class ProductsService extends Service {
public constructor(
@@ -74,6 +75,26 @@ export default class ProductsService extends Service {
});
},
},
applyComicVineMetadata: {
rest: "POST /applyComicVineMetadata",
params: {},
async handler(ctx: Context<{ match: object, comicObjectId: string }>) {
// 1. find mongo object by id
// 2. import payload into sourcedMetadata.comicvine
const comicObjectId = new ObjectId(ctx.params.comicObjectId);
return new Promise((resolve, reject) => {
Comic.findByIdAndUpdate(comicObjectId, { sourcedMetadata: { comicvine: ctx.params.match } }, { new: true}, (err, result) => {
if (err) {
console.log(err);
reject(err);
} else {
console.log("RES", result);
resolve(result);
}
})
});
}
},
getComicBooks: {
rest: "POST /getComicBooks",
params: {},

View File

@@ -85,6 +85,7 @@ export const extractCoverFromFile = async (
} catch (error) {
logger.error(`${error}: Couldn't create directory.`);
}
// extract the cover
let result: string;
const targetCoverImageFilePath = path.resolve(constructedPaths.targetPath + "/" + walkedFolder.name + "_cover.jpg")
result = await calibre.run(
@@ -203,6 +204,7 @@ export const unrar = async (
mode: 0o2775,
};
try {
// read the file into a buffer
const fileBuffer = await readFile(
paths.inputFilePath
).catch((err) => console.error("Failed to read file", err));