diff --git a/src/scripts/scrape-data/post-parse.ts b/src/scripts/scrape-data/post-parse.ts index d43b514..a0120aa 100644 --- a/src/scripts/scrape-data/post-parse.ts +++ b/src/scripts/scrape-data/post-parse.ts @@ -18,9 +18,9 @@ export interface ILink extends IPostElement { //#region Public methods /** - * Given the main post of the page (#1) it extracts the information contained. + * Given a post of a thread page it extracts the information contained in the body. */ -export function parseCheerioMainPost($: cheerio.Root, post: cheerio.Cheerio): IPostElement[] { +export function parseF95ThreadPost($: cheerio.Root, post: cheerio.Cheerio): IPostElement[] { // The data is divided between "tag" and "text" elements. // Simple data is composed of a "tag" element followed // by a "text" element, while more complex data (contained diff --git a/src/scripts/scrape-data/scrape-thread.ts b/src/scripts/scrape-data/scrape-thread.ts index 37bf0b2..a8e73cf 100644 --- a/src/scripts/scrape-data/scrape-thread.ts +++ b/src/scripts/scrape-data/scrape-thread.ts @@ -7,11 +7,11 @@ import luxon from "luxon"; // Modules from file import shared from "../shared.js"; import { fetchHTML } from "../network-helper.js"; -import { getJSONLD, TJsonLD } from "../json-ld.js"; +import { getJSONLD, TJsonLD } from "./json-ld.js"; import { selectors as f95Selector } from "../constants/css-selector.js"; import HandiWork from "../classes/handiwork/handiwork.js"; import { TRating, IBasic, TAuthor, TExternalPlatform, TEngine, TStatus, TCategory } from "../interfaces.js"; -import { ILink, IPostElement, parseCheerioMainPost } from "./post-parse.js"; +import { ILink, IPostElement, parseF95ThreadPost } from "./post-parse.js"; //#region Public methods /** @@ -19,7 +19,7 @@ import { ILink, IPostElement, parseCheerioMainPost } from "./post-parse.js"; * If you don't want to specify the object type, use `HandiWork`. * @todo It does not currently support assets. */ -export async function getPostInformation(url: string): Promise { +export async function getHandiworkInformation(url: string): Promise { shared.logger.info(`Obtaining post info from ${url}`); // Fetch HTML and prepare Cheerio @@ -31,7 +31,7 @@ export async function getPostInformation(url: string): Promise const mainPost = $(f95Selector.GS_POSTS).first(); // Extract data - const postData = parseCheerioMainPost($, mainPost); + const postData = parseF95ThreadPost($, mainPost); const TJsonLD = getJSONLD(body); // Fill in the HandiWork element with the information obtained @@ -170,7 +170,6 @@ function isMod(prefix: string): boolean { } //#endregion Prefix Utility - /** * Compiles a HandiWork object with the data extracted * from the JSON+LD tags related to the object itself. diff --git a/src/scripts/search.ts b/src/scripts/search.ts index 52ef777..a0a2e3c 100644 --- a/src/scripts/search.ts +++ b/src/scripts/search.ts @@ -5,7 +5,7 @@ import { IBasic } from "./interfaces.js"; import HandiworkSearchQuery from "./classes/query/handiwork-search-query.js"; import LatestSearchQuery from "./classes/query/latest-search-query.js"; import ThreadSearchQuery from "./classes/query/thread-search-query.js"; -import { getPostInformation } from "./scrape-data/scrape-thread.js"; +import { getHandiworkInformation } from "./scrape-data/scrape-thread.js"; import executeQuery from "./fetch-data/fetch-query.js"; export async function search(query: LatestSearchQuery, limit: number): Promise @@ -26,7 +26,7 @@ export default async function search(query: any, limit: number // Fetch the data const results = urls.map((url, idx) => { - return getPostInformation(url); + return getHandiworkInformation(url); }); return Promise.all(results);