mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
Add Somewhat working logic
This commit is contained in:
parent
2a4221e787
commit
5e9aa2b0ea
13 changed files with 461 additions and 54 deletions
|
|
@ -8,6 +8,8 @@ import crypto from "node:crypto";
|
|||
import { pythonRpcLogger } from "./logger";
|
||||
import { Readable } from "node:stream";
|
||||
import { app, dialog } from "electron";
|
||||
import { db, levelKeys } from "@main/level";
|
||||
import type { UserPreferences } from "@types";
|
||||
|
||||
interface GamePayload {
|
||||
game_id: string;
|
||||
|
|
@ -42,7 +44,7 @@ export class PythonRPC {
|
|||
readable.on("data", pythonRpcLogger.log);
|
||||
}
|
||||
|
||||
public static spawn(
|
||||
public static async spawn(
|
||||
initialDownload?: GamePayload,
|
||||
initialSeeding?: GamePayload[]
|
||||
) {
|
||||
|
|
@ -54,6 +56,15 @@ export class PythonRPC {
|
|||
initialSeeding ? JSON.stringify(initialSeeding) : "",
|
||||
];
|
||||
|
||||
const userPreferences = await db.get<string, UserPreferences | null>(levelKeys.userPreferences, {
|
||||
valueEncoding: "json",
|
||||
});
|
||||
|
||||
const env = {
|
||||
...process.env,
|
||||
ALLDEBRID_API_KEY: userPreferences?.allDebridApiKey || ""
|
||||
};
|
||||
|
||||
if (app.isPackaged) {
|
||||
const binaryName = binaryNameByPlatform[process.platform]!;
|
||||
const binaryPath = path.join(
|
||||
|
|
@ -74,6 +85,7 @@ export class PythonRPC {
|
|||
const childProcess = cp.spawn(binaryPath, commonArgs, {
|
||||
windowsHide: true,
|
||||
stdio: ["inherit", "inherit"],
|
||||
env
|
||||
});
|
||||
|
||||
this.logStderr(childProcess.stderr);
|
||||
|
|
@ -90,6 +102,7 @@ export class PythonRPC {
|
|||
|
||||
const childProcess = cp.spawn("python3", [scriptPath, ...commonArgs], {
|
||||
stdio: ["inherit", "inherit"],
|
||||
env
|
||||
});
|
||||
|
||||
this.logStderr(childProcess.stderr);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue