🔧 Moved scraping utils out of this service

This commit is contained in:
2022-02-16 20:25:48 -08:00
parent 2909d6686b
commit fdc1acd1ad
3 changed files with 4 additions and 18 deletions

View File

@@ -54,7 +54,6 @@ import {
IExtractionOptions,
} from "threetwo-ui-typings";
import { unrarArchive } from "../utils/uncompression.utils";
import { scrapeIssuesFromDOM } from "../utils/scraping.utils";
const ObjectId = require("mongoose").Types.ObjectId;
import fsExtra from "fs-extra";
const through2 = require("through2");
@@ -518,6 +517,7 @@ export default class ImportService extends Service {
};
},
},
flushDB: {
rest: "POST /flushDB",
params: {},
@@ -539,13 +539,7 @@ export default class ImportService extends Service {
.catch((error) => error);
},
},
scrapeIssueNamesFromDOM: {
rest: "POST /scrapeIssueNamesFromDOM",
params: {},
async handler(ctx: Context<{ html: string }>) {
return scrapeIssuesFromDOM(ctx.params.html);
},
},
unrarArchive: {
rest: "POST /unrarArchive",
params: {},

View File

@@ -1,8 +0,0 @@
const jsdom = require("jsdom");
const { JSDOM } = jsdom;
export const scrapeIssuesFromDOM = (html: string) => {
const dom = new JSDOM(html);
return dom.window.document.querySelector("p").textContent;
}

View File

@@ -100,13 +100,13 @@ export const extractCoverFromFile2 = async (
targetDirectory+
"/" +
fileNameWithoutExtension +
"_200px.jpg";
"_275px.jpg";
// 5. resize image
await resizeImage(
targetCoverImageFilePath,
path.resolve(renditionPath),
200
275
);
return {
name: fileNameWithoutExtension,