mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-03 00:33:49 +03:00
Merge branch 'feature/seed-completed-downloads' into feat/achievements-points
This commit is contained in:
commit
1115cc03b1
@ -12,6 +12,7 @@ torrent_port = sys.argv[1]
|
|||||||
http_port = sys.argv[2]
|
http_port = sys.argv[2]
|
||||||
rpc_password = sys.argv[3]
|
rpc_password = sys.argv[3]
|
||||||
start_download_payload = sys.argv[4]
|
start_download_payload = sys.argv[4]
|
||||||
|
start_seeding_payload = sys.argv[5]
|
||||||
|
|
||||||
downloads = {}
|
downloads = {}
|
||||||
# This can be streamed down from Node
|
# This can be streamed down from Node
|
||||||
@ -32,6 +33,12 @@ if start_download_payload:
|
|||||||
downloads[initial_download['game_id']] = http_downloader
|
downloads[initial_download['game_id']] = http_downloader
|
||||||
http_downloader.start_download(initial_download['url'], initial_download['save_path'], initial_download.get('header'))
|
http_downloader.start_download(initial_download['url'], initial_download['save_path'], initial_download.get('header'))
|
||||||
|
|
||||||
|
if start_seeding_payload:
|
||||||
|
initial_seeding = json.loads(urllib.parse.unquote(start_seeding_payload))
|
||||||
|
for seed in initial_seeding:
|
||||||
|
torrent_downloader = TorrentDownloader(torrent_session)
|
||||||
|
downloads[seed['game_id']] = torrent_downloader
|
||||||
|
torrent_downloader.start_download(seed['url'], seed['save_path'], "")
|
||||||
|
|
||||||
def validate_rpc_password():
|
def validate_rpc_password():
|
||||||
"""Middleware to validate RPC password."""
|
"""Middleware to validate RPC password."""
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { DownloadManager, Ludusavi, startMainLoop } from "./services";
|
import { DownloadManager, Ludusavi, startMainLoop } from "./services";
|
||||||
import {
|
import {
|
||||||
downloadQueueRepository,
|
downloadQueueRepository,
|
||||||
|
gameRepository,
|
||||||
userPreferencesRepository,
|
userPreferencesRepository,
|
||||||
} from "./repository";
|
} from "./repository";
|
||||||
import { UserPreferences } from "./entity";
|
import { UserPreferences } from "./entity";
|
||||||
@ -8,7 +9,6 @@ import { RealDebridClient } from "./services/download/real-debrid";
|
|||||||
import { HydraApi } from "./services/hydra-api";
|
import { HydraApi } from "./services/hydra-api";
|
||||||
import { uploadGamesBatch } from "./services/library-sync";
|
import { uploadGamesBatch } from "./services/library-sync";
|
||||||
import { Aria2 } from "./services/aria2";
|
import { Aria2 } from "./services/aria2";
|
||||||
import { startSeedProcess } from "./services/seed";
|
|
||||||
import { PythonRPC } from "./services/python-rpc";
|
import { PythonRPC } from "./services/python-rpc";
|
||||||
|
|
||||||
const loadState = async (userPreferences: UserPreferences | null) => {
|
const loadState = async (userPreferences: UserPreferences | null) => {
|
||||||
@ -35,14 +35,20 @@ const loadState = async (userPreferences: UserPreferences | null) => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const seedList = await gameRepository.find({
|
||||||
|
where: {
|
||||||
|
shouldSeed: true,
|
||||||
|
downloader: 1,
|
||||||
|
progress: 1,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
if (nextQueueItem?.game.status === "active") {
|
if (nextQueueItem?.game.status === "active") {
|
||||||
DownloadManager.startRPC(nextQueueItem.game);
|
DownloadManager.startRPC(nextQueueItem.game, seedList);
|
||||||
} else {
|
} else {
|
||||||
PythonRPC.spawn();
|
PythonRPC.spawn();
|
||||||
}
|
}
|
||||||
|
|
||||||
await startSeedProcess();
|
|
||||||
|
|
||||||
startMainLoop();
|
startMainLoop();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -24,13 +24,20 @@ import { logger } from "../logger";
|
|||||||
export class DownloadManager {
|
export class DownloadManager {
|
||||||
private static downloadingGameId: number | null = null;
|
private static downloadingGameId: number | null = null;
|
||||||
|
|
||||||
public static startRPC(game: Game) {
|
public static startRPC(game: Game, initialSeeding?: Game[]) {
|
||||||
if (game && game.status === "active") {
|
if (game && game.status === "active") {
|
||||||
PythonRPC.spawn({
|
PythonRPC.spawn(
|
||||||
game_id: game.id,
|
{
|
||||||
url: game.uri!,
|
game_id: game.id,
|
||||||
save_path: game.downloadPath!,
|
url: game.uri!,
|
||||||
});
|
save_path: game.downloadPath!,
|
||||||
|
},
|
||||||
|
initialSeeding?.map((game) => ({
|
||||||
|
game_id: game.id,
|
||||||
|
url: game.uri!,
|
||||||
|
save_path: game.downloadPath!,
|
||||||
|
}))
|
||||||
|
);
|
||||||
|
|
||||||
this.downloadingGameId = game.id;
|
this.downloadingGameId = game.id;
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ import { logger } from "./logger";
|
|||||||
import { Readable } from "node:stream";
|
import { Readable } from "node:stream";
|
||||||
import { app, dialog } from "electron";
|
import { app, dialog } from "electron";
|
||||||
|
|
||||||
interface StartDownloadPayload {
|
interface GamePayload {
|
||||||
game_id: number;
|
game_id: number;
|
||||||
url: string;
|
url: string;
|
||||||
save_path: string;
|
save_path: string;
|
||||||
@ -42,12 +42,16 @@ export class PythonRPC {
|
|||||||
readable.on("data", logger.log);
|
readable.on("data", logger.log);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static spawn(initialDownload?: StartDownloadPayload) {
|
public static spawn(
|
||||||
|
initialDownload?: GamePayload,
|
||||||
|
initialSeeding?: GamePayload[]
|
||||||
|
) {
|
||||||
const commonArgs = [
|
const commonArgs = [
|
||||||
this.BITTORRENT_PORT,
|
this.BITTORRENT_PORT,
|
||||||
this.RPC_PORT,
|
this.RPC_PORT,
|
||||||
this.RPC_PASSWORD,
|
this.RPC_PASSWORD,
|
||||||
initialDownload ? JSON.stringify(initialDownload) : "",
|
initialDownload ? JSON.stringify(initialDownload) : "",
|
||||||
|
initialSeeding ? JSON.stringify(initialSeeding) : "",
|
||||||
];
|
];
|
||||||
|
|
||||||
if (app.isPackaged) {
|
if (app.isPackaged) {
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
import { gameRepository } from "@main/repository";
|
|
||||||
import { DownloadManager } from "./download/download-manager";
|
|
||||||
import { sleep } from "@main/helpers";
|
|
||||||
|
|
||||||
export const startSeedProcess = async () => {
|
|
||||||
const seedList = await gameRepository.find({
|
|
||||||
where: {
|
|
||||||
shouldSeed: true,
|
|
||||||
downloader: 1,
|
|
||||||
progress: 1,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (seedList.length === 0) return;
|
|
||||||
await sleep(1000);
|
|
||||||
|
|
||||||
seedList.map(async (game) => {
|
|
||||||
await DownloadManager.startDownload(game);
|
|
||||||
await sleep(300);
|
|
||||||
});
|
|
||||||
};
|
|
Loading…
Reference in New Issue
Block a user