fix: fixing typechecks

This commit is contained in:
Hydra
2024-04-25 20:54:38 +01:00
parent c07f82ce49
commit f9223ad36d
21 changed files with 311 additions and 90 deletions

View File

@@ -19,17 +19,17 @@ export const getNewRepacksFromCPG = async (
try {
Array.from(window.document.querySelectorAll(".post")).forEach(($post) => {
const $title = $post.querySelector(".entry-title");
const uploadDate = $post.querySelector("time").getAttribute("datetime");
const uploadDate = $post.querySelector("time")?.getAttribute("datetime");
const $downloadInfo = Array.from(
$post.querySelectorAll(".wp-block-heading")
).find(($heading) => $heading.textContent.startsWith("Download"));
).find(($heading) => $heading.textContent?.startsWith("Download"));
/* Side note: CPG often misspells "Magnet" as "Magent" */
const $magnet = Array.from($post.querySelectorAll("a")).find(
($a) =>
$a.textContent.startsWith("Magnet") ||
$a.textContent.startsWith("Magent")
$a.textContent?.startsWith("Magnet") ||
$a.textContent?.startsWith("Magent")
);
const fileSize = $downloadInfo.textContent

View File

@@ -2,4 +2,4 @@ export * from "./1337x";
export * from "./xatab";
export * from "./cpg-repacks";
export * from "./gog";
// export * from "./online-fix";
export * from "./online-fix";

View File

@@ -88,7 +88,7 @@ export const getNewRepacksFromOnlineFix = async (
const repacks: GameRepackInput[] = [];
const articles = Array.from(document.querySelectorAll(".news"));
const totalPages = Number(
document.querySelector("nav > a:nth-child(13)").textContent
document.querySelector("nav > a:nth-child(13)")?.textContent
);
try {
@@ -186,8 +186,10 @@ export const getNewRepacksFromOnlineFix = async (
});
})
);
} catch (err) {
logger.error(err.message, { method: "getNewRepacksFromOnlineFix" });
} catch (err: unknown) {
logger.error((err as Error).message, {
method: "getNewRepacksFromOnlineFix",
});
}
const newRepacks = repacks.filter(