mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-03 00:33:49 +03:00
improve xatab scrap performance and update seed with xatab repacks
This commit is contained in:
parent
b330c94dca
commit
5908544602
@ -12,6 +12,9 @@ import { formatBytes } from "@shared";
|
|||||||
import { getFileBuffer } from "@main/helpers";
|
import { getFileBuffer } from "@main/helpers";
|
||||||
|
|
||||||
const worker = createWorker({});
|
const worker = createWorker({});
|
||||||
|
worker.setMaxListeners(11);
|
||||||
|
|
||||||
|
let totalPages = 1;
|
||||||
|
|
||||||
const formatXatabDate = (str: string) => {
|
const formatXatabDate = (str: string) => {
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
@ -69,27 +72,37 @@ export const getNewRepacksFromXatab = async (
|
|||||||
|
|
||||||
const repacks: QueryDeepPartialEntity<Repack>[] = [];
|
const repacks: QueryDeepPartialEntity<Repack>[] = [];
|
||||||
|
|
||||||
for (const $a of Array.from(
|
if (page === 1) {
|
||||||
window.document.querySelectorAll(".entry__title a")
|
totalPages = Number(
|
||||||
)) {
|
window.document.querySelector(
|
||||||
try {
|
"#bottom-nav > div.pagination > a:nth-child(12)"
|
||||||
const repack = await getXatabRepack(($a as HTMLAnchorElement).href);
|
)?.textContent
|
||||||
|
);
|
||||||
if (repack) {
|
|
||||||
repacks.push({
|
|
||||||
title: $a.textContent!,
|
|
||||||
repacker: "Xatab",
|
|
||||||
...repack,
|
|
||||||
page,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} catch (err: unknown) {
|
|
||||||
logger.error((err as Error).message, {
|
|
||||||
method: "getNewRepacksFromXatab",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const repacksFromPage = Array.from(
|
||||||
|
window.document.querySelectorAll(".entry__title a")
|
||||||
|
).map(($a) => {
|
||||||
|
return getXatabRepack(($a as HTMLAnchorElement).href)
|
||||||
|
.then((repack) => {
|
||||||
|
if (repack) {
|
||||||
|
repacks.push({
|
||||||
|
title: $a.textContent!,
|
||||||
|
repacker: "Xatab",
|
||||||
|
...repack,
|
||||||
|
page,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((err: unknown) => {
|
||||||
|
logger.error((err as Error).message, {
|
||||||
|
method: "getNewRepacksFromXatab",
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
await Promise.all(repacksFromPage);
|
||||||
|
|
||||||
const newRepacks = repacks.filter(
|
const newRepacks = repacks.filter(
|
||||||
(repack) =>
|
(repack) =>
|
||||||
!existingRepacks.some(
|
!existingRepacks.some(
|
||||||
@ -98,6 +111,7 @@ export const getNewRepacksFromXatab = async (
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (!newRepacks.length) return;
|
if (!newRepacks.length) return;
|
||||||
|
if (page === totalPages) return;
|
||||||
|
|
||||||
await savePage(newRepacks);
|
await savePage(newRepacks);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user