Skip to content

Commit

Permalink
Merge pull request #331 from hydralauncher/feat/bypass-shop-block
Browse files Browse the repository at this point in the history
Feat/bypass shop block
  • Loading branch information
Hydra authored May 13, 2024
2 parents 38b88d0 + 301d9a5 commit 51129bf
Show file tree
Hide file tree
Showing 46 changed files with 480 additions and 508 deletions.
Empty file removed resources/hydra.db
Empty file.
1 change: 0 additions & 1 deletion src/locales/be/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@
"repacks_modal_description": "Абярыце рэпак, які хочаце сьцягнуць",
"downloads_path": "Шлях сьцягваньня",
"select_folder_hint": "Каб зьмяніць папку па змоўчаньні, адкрыйце",
"settings": "Налады Hydra",
"download_now": "Сьцягнуць зараз",
"installation_instructions": "Інструкцыя ўсталёўкі",
"installation_instructions_description": "Усталёўка гэтай гульні патрабуе дадатковых крокаў",
Expand Down
6 changes: 4 additions & 2 deletions src/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@
"playing_now": "Playing now",
"change": "Change",
"repacks_modal_description": "Choose the repack you want to download",
"downloads_path": "Downloads path",
"select_folder_hint": "To change the default folder, go to the <0>Settings</0>",
"download_now": "Download now",
"installation_instructions": "Installation Instructions",
Expand All @@ -97,6 +96,9 @@
"copy_to_clipboard": "Copy",
"copied_to_clipboard": "Copied",
"got_it": "Got it",
"no_shop_details": "Could not retrieve shop details.",
"download_options": "Download options",
"download_path": "Download path",
"previous_screenshot": "Previous screenshot",
"next_screenshot": "Next screenshot",
"screenshot": "Screenshot {{number}}",
Expand Down Expand Up @@ -143,7 +145,7 @@
"enable_repack_list_notifications": "When a new repack is added",
"telemetry": "Telemetry",
"telemetry_description": "Enable anonymous usage statistics",
"real_debrid_api_token_description": "Real Debrid API token",
"real_debrid_api_token_label": "Real Debrid API token",
"quit_app_instead_hiding": "Quit Hydra instead of minimizing to tray",
"launch_with_system": "Launch Hydra on system start-up",
"general": "General",
Expand Down
1 change: 0 additions & 1 deletion src/locales/es/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@
"repacks_modal_description": "Selecciona el repack que quieres descargar",
"downloads_path": "Ruta de descarga",
"select_folder_hint": "Para cambiar la carpeta predeterminada, accede a",
"settings": "Ajustes",
"download_now": "Descargar ahora",
"installation_instructions": "Instrucciones de instalación",
"installation_instructions_description": "Se requieren de pasos adicionales para instalar este juego",
Expand Down
1 change: 0 additions & 1 deletion src/locales/id/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@
"repacks_modal_description": "Pilih repack yang kamu ingin unduh",
"downloads_path": "Lokasi Unduhan",
"select_folder_hint": "Untuk merubah folder bawaan, akses melalui",
"settings": "Pengaturan",
"download_now": "Unduh sekarang",
"installation_instructions": "Instruksi Instalasi",
"installation_instructions_description": "Langkah tambahan dibutuhkan untuk meng-instal game ini",
Expand Down
1 change: 0 additions & 1 deletion src/locales/it/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@
"repacks_modal_description": "Scegli il repack che vuoi scaricare",
"downloads_path": "Percorso dei download",
"select_folder_hint": "Per cambiare la cartella predefinita, accedi alle",
"settings": "Impostazioni",
"download_now": "Scarica ora",
"installation_instructions": "Istruzioni di installazione",
"installation_instructions_description": "Sono necessari passaggi aggiuntivi per installare questo gioco",
Expand Down
2 changes: 1 addition & 1 deletion src/locales/nl/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
"enable_repack_list_notifications": "Wanneer een nieuwe herverpakking wordt toegevoegd",
"telemetry": "Telemetrie",
"telemetry_description": "Schakel anonieme gebruiksstatistieken in",
"real_debrid_api_token_description": "Real Debrid API token",
"real_debrid_api_token_label": "Real Debrid API token",
"quit_app_instead_hiding": "Sluit Hydra af in plaats van te minimaliseren naar de lade",
"launch_with_system": "Start Hydra bij het opstarten van het systeem",
"general": "Algemeen",
Expand Down
1 change: 0 additions & 1 deletion src/locales/pl/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@
"repacks_modal_description": "Wybierz repack, który chcesz pobrać",
"downloads_path": "Ścieżka pobierania",
"select_folder_hint": "Aby zmienić domyślny folder, przejdź do",
"settings": "Ustawienia Hydra",
"download_now": "Pobierz teraz"
},
"activation": {
Expand Down
9 changes: 7 additions & 2 deletions src/locales/pt/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@
"playing_now": "Jogando agora",
"change": "Mudar",
"repacks_modal_description": "Escolha o repack do jogo que deseja baixar",
"downloads_path": "Diretório do download",
"select_folder_hint": "Para trocar a pasta padrão, acesse a <0>Tela de Configurações</0>",
"download_now": "Baixe agora",
"installation_instructions": "Instruções de Instalação",
Expand All @@ -93,6 +92,9 @@
"copy_to_clipboard": "Copiar",
"copied_to_clipboard": "Copiado",
"got_it": "Entendi",
"no_shop_details": "Não foi possível obter os detalhes da loja.",
"download_options": "Opções de download",
"download_path": "Diretório de download",
"previous_screenshot": "Captura de tela anterior",
"next_screenshot": "Próxima captura de tela",
"screenshot": "Captura de tela {{number}}",
Expand Down Expand Up @@ -127,7 +129,9 @@
"delete_modal_description": "Isso removerá todos os arquivos de instalação do seu computador",
"delete_modal_title": "Tem certeza?",
"deleting": "Excluindo instalador…",
"install": "Instalar"
"install": "Instalar",
"torrent": "Torrent",
"real_debrid": "Real Debrid"
},
"settings": {
"downloads_path": "Diretório dos downloads",
Expand All @@ -137,6 +141,7 @@
"enable_repack_list_notifications": "Quando a lista de repacks for atualizada",
"telemetry": "Telemetria",
"telemetry_description": "Habilitar estatísticas de uso anônimas",
"real_debrid_api_token_label": "Token de API do Real Debrid",
"quit_app_instead_hiding": "Fechar o aplicativo em vez de minimizá-lo",
"launch_with_system": "Iniciar aplicativo na inicialização do sistema",
"general": "Geral",
Expand Down
1 change: 0 additions & 1 deletion src/locales/ru/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@
"repacks_modal_description": "Выберите репак для загрузки",
"downloads_path": "Путь загрузок",
"select_folder_hint": "Изменить папку по умолчанию",
"settings": "Настройки Hydra",
"download_now": "Загрузить сейчас",
"installation_instructions": "Инструкция по установке",
"installation_instructions_description": "Для установки этой игры требуются дополнительные шаги",
Expand Down
1 change: 0 additions & 1 deletion src/locales/tr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@
"repacks_modal_description": "İndirmek istediğiiniz repacki seçin",
"downloads_path": "İndirme yolu",
"select_folder_hint": "Varsayılan klasörü değiştirmek için ulaşmanız gereken ayar",
"settings": "Ayarlar",
"download_now": "Şimdi",
"installation_instructions": "Kurulum",
"installation_instructions_description": "Bu oyunu kurmak için ek adımlar gerekiyor",
Expand Down
1 change: 0 additions & 1 deletion src/locales/uk/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@
"repacks_modal_description": "Виберіть репак, який хочете завантажити",
"downloads_path": "Шлях завантажень",
"select_folder_hint": "Щоб змінити теку за замовчуванням, відкрийте",
"settings": "Налаштування Hydra",
"download_now": "Завантажити зараз",
"installation_instructions": "Інструкція зі встановлення",
"installation_instructions_description": "Для встановлення цієї гри потрібні додаткові кроки",
Expand Down
56 changes: 31 additions & 25 deletions src/main/events/catalogue/get-game-shop-details.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,32 @@
import { gameShopCacheRepository } from "@main/repository";
import { gameShopCacheRepository, steamGameRepository } from "@main/repository";
import { getSteamAppDetails } from "@main/services";

import type { ShopDetails, GameShop, SteamAppDetails } from "@types";

import { registerEvent } from "../register-event";
import { searchRepacks } from "../helpers/search-games";

const getLocalizedSteamAppDetails = (
objectID: string,
language: string
): Promise<ShopDetails | null> => {
if (language === "english") {
return getSteamAppDetails(objectID, language);
}

return Promise.all([
steamGameRepository.findOne({ where: { id: Number(objectID) } }),
getSteamAppDetails(objectID, language),
]).then(([steamGame, localizedAppDetails]) => {
if (steamGame && localizedAppDetails) {
return {
...localizedAppDetails,
name: steamGame.name,
};
}

return null;
});
};

const getGameShopDetails = async (
_event: Electron.IpcMainInvokeEvent,
Expand All @@ -17,27 +39,21 @@ const getGameShopDetails = async (
where: { objectID, language },
});

const result = Promise.all([
getSteamAppDetails(objectID, "english"),
getSteamAppDetails(objectID, language),
]).then(([appDetails, localizedAppDetails]) => {
if (appDetails && localizedAppDetails) {
const appDetails = getLocalizedSteamAppDetails(objectID, language).then(
(result) => {
gameShopCacheRepository.upsert(
{
objectID,
shop: "steam",
language,
serializedData: JSON.stringify({
...localizedAppDetails,
name: appDetails.name,
}),
serializedData: JSON.stringify(result),
},
["objectID"]
);
}

return [appDetails, localizedAppDetails];
});
return result;
}
);

const cachedGame = cachedData?.serializedData
? (JSON.parse(cachedData?.serializedData) as SteamAppDetails)
Expand All @@ -46,21 +62,11 @@ const getGameShopDetails = async (
if (cachedGame) {
return {
...cachedGame,
repacks: searchRepacks(cachedGame.name),
objectID,
} as ShopDetails;
}

return result.then(([appDetails, localizedAppDetails]) => {
if (!appDetails || !localizedAppDetails) return null;

return {
...localizedAppDetails,
name: appDetails.name,
repacks: searchRepacks(appDetails.name),
objectID,
} as ShopDetails;
});
return Promise.resolve(appDetails);
}

throw new Error("Not implemented");
Expand Down
7 changes: 3 additions & 4 deletions src/main/events/catalogue/get-random-game.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { shuffle } from "lodash-es";

import { Steam250Game, getSteam250List } from "@main/services";
import { getSteam250List } from "@main/services";

import { registerEvent } from "../register-event";
import { searchGames, searchRepacks } from "../helpers/search-games";
import type { Steam250Game } from "@types";

const state = { games: Array<Steam250Game>(), index: 0 };

Expand All @@ -25,16 +26,14 @@ const getRandomGame = async (_event: Electron.IpcMainInvokeEvent) => {
return "";
}

const resultObjectId = state.games[state.index].objectID;

state.index += 1;

if (state.index == state.games.length) {
state.index = 0;
state.games = shuffle(state.games);
}

return resultObjectId;
return state.games[state.index];
};

registerEvent(getRandomGame, {
Expand Down
14 changes: 14 additions & 0 deletions src/main/events/catalogue/search-game-repacks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { searchRepacks } from "../helpers/search-games";
import { registerEvent } from "../register-event";

const searchGameRepacks = (
_event: Electron.IpcMainInvokeEvent,
query: string
) => {
return searchRepacks(query);
};

registerEvent(searchGameRepacks, {
name: "searchGameRepacks",
memoize: true,
});
1 change: 1 addition & 0 deletions src/main/events/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import "./catalogue/get-games";
import "./catalogue/get-how-long-to-beat";
import "./catalogue/get-random-game";
import "./catalogue/search-games";
import "./catalogue/search-game-repacks";
import "./hardware/get-disk-free-space";
import "./library/add-game-to-library";
import "./library/close-game";
Expand Down
9 changes: 3 additions & 6 deletions src/main/services/real-debrid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ export class RealDebridClient {
private static instance: AxiosInstance;

static async addMagnet(magnet: string) {
const searchParams = new URLSearchParams();
searchParams.append("magnet", magnet);
const searchParams = new URLSearchParams({ magnet });

const response = await this.instance.post<RealDebridAddMagnet>(
"/torrents/addMagnet",
Expand All @@ -31,8 +30,7 @@ export class RealDebridClient {
}

static async selectAllFiles(id: string) {
const searchParams = new URLSearchParams();
searchParams.append("files", "all");
const searchParams = new URLSearchParams({ files: "all" });

await this.instance.post(
`/torrents/selectFiles/${id}`,
Expand All @@ -41,8 +39,7 @@ export class RealDebridClient {
}

static async unrestrictLink(link: string) {
const searchParams = new URLSearchParams();
searchParams.append("link", link);
const searchParams = new URLSearchParams({ link });

const response = await this.instance.post<RealDebridUnrestrictLink>(
"/unrestrict/link",
Expand Down
5 changes: 1 addition & 4 deletions src/main/services/steam-250.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import axios from "axios";
import { JSDOM } from "jsdom";

export interface Steam250Game {
title: string;
objectID: string;
}
import type { Steam250Game } from "@types";

export const requestSteam250 = async (path: string) => {
return axios
Expand Down
Loading

0 comments on commit 51129bf

Please sign in to comment.