diff --git a/src/scripts/scrape-data/handiwork-parse.ts b/src/scripts/scrape-data/handiwork-parse.ts index c2838bc..5e4cd85 100644 --- a/src/scripts/scrape-data/handiwork-parse.ts +++ b/src/scripts/scrape-data/handiwork-parse.ts @@ -17,13 +17,22 @@ import { ILink, IPostElement } from "./post-parse.js"; * * @todo It does not currently support assets. */ -export default async function getHandiworkInformation(url: string): Promise { - shared.logger.info(`Obtaining handiwork from ${url}`); +export async function getHandiworkInformation(url: string): Promise - // Fetch thread data - const id = extractIDFromURL(url); - const thread: Thread = new Thread(id); - await thread.fetch(); +export async function getHandiworkInformation(url: string): Promise + +export default async function getHandiworkInformation(arg: string | Thread): Promise { + // Local variables + let thread: Thread = null; + + if (typeof arg === "string") { + // Fetch thread data + const id = extractIDFromURL(arg); + thread = new Thread(id); + await thread.fetch(); + } else thread = arg; + + shared.logger.info(`Obtaining handiwork from ${thread.url}`); // Convert the info from thread to handiwork const hw: HandiWork = {} as HandiWork; @@ -40,9 +49,9 @@ export default async function getHandiworkInformation(url: str // Fetch info from first post const post = await thread.getPost(1); fillWithPostData(hw, post.body); - + return hw; -}; +} //#region Private methods