mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
fix: resolve many minor change requests
This commit is contained in:
parent
0b7db6cf13
commit
68478fa6f2
6 changed files with 623 additions and 20695 deletions
20207
package-lock.json
generated
20207
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -85,7 +85,7 @@
|
|||
"i18next-browser-languagedetector": "^7.2.0",
|
||||
"jsdom": "^24.0.0",
|
||||
"lodash": "^4.17.21",
|
||||
"parse-torrent": "^9.1.5",
|
||||
"parse-torrent": "9.1.5",
|
||||
"pretty-bytes": "^6.1.1",
|
||||
"qs": "^6.12.0",
|
||||
"react": "^18.2.0",
|
||||
|
@ -103,7 +103,6 @@
|
|||
"vite-plugin-svgr": "^4.2.0",
|
||||
"vite-tsconfig-paths": "^4.3.2",
|
||||
"windows-1251": "^3.0.4",
|
||||
"winston": "^3.12.0",
|
||||
"zod": "^3.22.4"
|
||||
"winston": "^3.12.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,15 +13,11 @@ const repacksIndex = new Index();
|
|||
const repacks = stateManager.getValue("repacks");
|
||||
|
||||
for (let i = 0; i < repacks.length; i++) {
|
||||
try {
|
||||
const repack = repacks[i];
|
||||
const formatter =
|
||||
repackerFormatter[repack.repacker as keyof typeof repackerFormatter];
|
||||
const repack = repacks[i];
|
||||
const formatter =
|
||||
repackerFormatter[repack.repacker as keyof typeof repackerFormatter];
|
||||
|
||||
repacksIndex.add(i, formatName(formatter(repack.title)));
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
repacksIndex.add(i, formatName(formatter(repack.title)));
|
||||
}
|
||||
|
||||
export const HITS_PER_PAGE = 12;
|
||||
|
|
|
@ -47,7 +47,8 @@ export const xatabFormatter = (title: string) =>
|
|||
.replace(/(v\.?([0-9]| )+)+([0-9]|\.|-|_|\/|[a-zA-Z]| )+/, "");
|
||||
|
||||
export const tinyRepacksFormatter = (title: string) => title;
|
||||
export const onlinefixFormatter = (title: string) => title;
|
||||
export const onlinefixFormatter = (title: string) =>
|
||||
title.replace("по сети", "").trim();
|
||||
|
||||
export const gogFormatter = (title: string) =>
|
||||
title.replace(/(v\.[0-9]+|v[0-9]+\.|v[0-9]{4})+.+/, "");
|
||||
|
|
|
@ -3,7 +3,6 @@ import { savePage } from "./helpers";
|
|||
import type { GameRepackInput } from "./helpers";
|
||||
import { logger } from "../logger";
|
||||
import { stringify } from "qs";
|
||||
import { z } from "zod";
|
||||
import parseTorrent, { toMagnetURI } from "parse-torrent";
|
||||
import { JSDOM } from "jsdom";
|
||||
import { gotScraping } from "got-scraping";
|
||||
|
@ -13,11 +12,6 @@ import { format, parse, sub } from "date-fns";
|
|||
import { ru } from "date-fns/locale";
|
||||
import { decode } from "windows-1251";
|
||||
|
||||
const preLoginSchema = z.object({
|
||||
field: z.string(),
|
||||
value: z.string(),
|
||||
});
|
||||
|
||||
export const getNewRepacksFromOnlineFix = async (
|
||||
existingRepacks: Repack[] = []
|
||||
): Promise<void> => {
|
||||
|
@ -42,18 +36,23 @@ export const getNewRepacksFromOnlineFix = async (
|
|||
});
|
||||
|
||||
await http.get("https://online-fix.me/");
|
||||
const preLogin = await http
|
||||
.get("https://online-fix.me/engine/ajax/authtoken.php", {
|
||||
headers: {
|
||||
"X-Requested-With": "XMLHttpRequest",
|
||||
Referer: "https://online-fix.me/",
|
||||
},
|
||||
})
|
||||
.json();
|
||||
const preLogin =
|
||||
((await http
|
||||
.get("https://online-fix.me/engine/ajax/authtoken.php", {
|
||||
headers: {
|
||||
"X-Requested-With": "XMLHttpRequest",
|
||||
Referer: "https://online-fix.me/",
|
||||
},
|
||||
})
|
||||
.json()) as {
|
||||
field: string;
|
||||
value: string;
|
||||
}) || undefined;
|
||||
|
||||
const parsedPreLoginRes = preLoginSchema.parse(preLogin);
|
||||
const tokenField = parsedPreLoginRes.field;
|
||||
const tokenValue = parsedPreLoginRes.value;
|
||||
if (!preLogin.field || !preLogin.value) return;
|
||||
|
||||
const tokenField = preLogin.field;
|
||||
const tokenValue = preLogin.value;
|
||||
|
||||
const login = await http
|
||||
.post("https://online-fix.me/", {
|
||||
|
@ -82,9 +81,7 @@ export const getNewRepacksFromOnlineFix = async (
|
|||
articles.map(async (article) => {
|
||||
const gameName = decode(
|
||||
article.querySelector("h2.title")?.textContent?.trim()
|
||||
)
|
||||
.replace("по сети", "")
|
||||
.trim();
|
||||
);
|
||||
|
||||
const gameLink = article.querySelector("a")?.getAttribute("href");
|
||||
|
||||
|
@ -99,20 +96,18 @@ export const getNewRepacksFromOnlineFix = async (
|
|||
const gameDom = new JSDOM(gamePage);
|
||||
const gameDocument = gameDom.window.document;
|
||||
|
||||
const uploadDateText = gameDocument.querySelector(
|
||||
"#dle-content > div > article > div.full-story-header.wide-block.clr > div.full-story-top-panel.clr > div.date.left > time"
|
||||
).textContent;
|
||||
const uploadDateText = gameDocument.querySelector("time").textContent;
|
||||
|
||||
let decodedDateText = decode(uploadDateText);
|
||||
|
||||
// "Вчера" significa ontem.
|
||||
// "Вчера" means yesterday.
|
||||
if (decodedDateText.includes("Вчера")) {
|
||||
const yesterday = sub(new Date(), { days: 1 });
|
||||
const formattedYesterday = format(yesterday, "d LLLL yyyy", {
|
||||
locale: ru,
|
||||
});
|
||||
decodedDateText = decodedDateText.replace(
|
||||
"Вчера",
|
||||
"Вчера", // "Change yesterday to the default expected date format"
|
||||
formattedYesterday
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue