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