🔧 Moved scraping utils out of this service
This commit is contained in:
@@ -54,7 +54,6 @@ import {
|
|||||||
IExtractionOptions,
|
IExtractionOptions,
|
||||||
} from "threetwo-ui-typings";
|
} from "threetwo-ui-typings";
|
||||||
import { unrarArchive } from "../utils/uncompression.utils";
|
import { unrarArchive } from "../utils/uncompression.utils";
|
||||||
import { scrapeIssuesFromDOM } from "../utils/scraping.utils";
|
|
||||||
const ObjectId = require("mongoose").Types.ObjectId;
|
const ObjectId = require("mongoose").Types.ObjectId;
|
||||||
import fsExtra from "fs-extra";
|
import fsExtra from "fs-extra";
|
||||||
const through2 = require("through2");
|
const through2 = require("through2");
|
||||||
@@ -518,6 +517,7 @@ export default class ImportService extends Service {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
flushDB: {
|
flushDB: {
|
||||||
rest: "POST /flushDB",
|
rest: "POST /flushDB",
|
||||||
params: {},
|
params: {},
|
||||||
@@ -539,13 +539,7 @@ export default class ImportService extends Service {
|
|||||||
.catch((error) => error);
|
.catch((error) => error);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
scrapeIssueNamesFromDOM: {
|
|
||||||
rest: "POST /scrapeIssueNamesFromDOM",
|
|
||||||
params: {},
|
|
||||||
async handler(ctx: Context<{ html: string }>) {
|
|
||||||
return scrapeIssuesFromDOM(ctx.params.html);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
unrarArchive: {
|
unrarArchive: {
|
||||||
rest: "POST /unrarArchive",
|
rest: "POST /unrarArchive",
|
||||||
params: {},
|
params: {},
|
||||||
|
|||||||
@@ -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;
|
|
||||||
}
|
|
||||||
@@ -100,13 +100,13 @@ export const extractCoverFromFile2 = async (
|
|||||||
targetDirectory+
|
targetDirectory+
|
||||||
"/" +
|
"/" +
|
||||||
fileNameWithoutExtension +
|
fileNameWithoutExtension +
|
||||||
"_200px.jpg";
|
"_275px.jpg";
|
||||||
|
|
||||||
// 5. resize image
|
// 5. resize image
|
||||||
await resizeImage(
|
await resizeImage(
|
||||||
targetCoverImageFilePath,
|
targetCoverImageFilePath,
|
||||||
path.resolve(renditionPath),
|
path.resolve(renditionPath),
|
||||||
200
|
275
|
||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
name: fileNameWithoutExtension,
|
name: fileNameWithoutExtension,
|
||||||
|
|||||||
Reference in New Issue
Block a user