mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-02 16:23:48 +03:00
Merge branch 'feature/seed-completed-downloads' into feat/achievements-points
This commit is contained in:
commit
0f396b83f1
@ -148,6 +148,14 @@ def action():
|
|||||||
downloader = downloads.get(game_id)
|
downloader = downloads.get(game_id)
|
||||||
if downloader:
|
if downloader:
|
||||||
downloader.cancel_download()
|
downloader.cancel_download()
|
||||||
|
elif action == 'resume_seeding':
|
||||||
|
torrent_downloader = TorrentDownloader(torrent_session)
|
||||||
|
downloads[game_id] = torrent_downloader
|
||||||
|
torrent_downloader.start_download(data['url'], data['save_path'], "")
|
||||||
|
elif action == 'pause_seeding':
|
||||||
|
downloader = downloads.get(game_id)
|
||||||
|
if downloader:
|
||||||
|
downloader.cancel_download()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
return jsonify({"error": "Invalid action"}), 400
|
return jsonify({"error": "Invalid action"}), 400
|
||||||
|
@ -15,8 +15,8 @@ class ProfileImageProcessor:
|
|||||||
mime_type = image.get_format_mimetype()
|
mime_type = image.get_format_mimetype()
|
||||||
return image_path, mime_type
|
return image_path, mime_type
|
||||||
else:
|
else:
|
||||||
newUUID = str(uuid.uuid4())
|
new_uuid = str(uuid.uuid4())
|
||||||
new_image_path = os.path.join(tempfile.gettempdir(), newUUID) + ".webp"
|
new_image_path = os.path.join(tempfile.gettempdir(), new_uuid) + ".webp"
|
||||||
image.save(new_image_path)
|
image.save(new_image_path)
|
||||||
|
|
||||||
new_image = Image.open(new_image_path)
|
new_image = Image.open(new_image_path)
|
||||||
|
@ -11,7 +11,7 @@ const pauseGameSeed = async (
|
|||||||
shouldSeed: false,
|
shouldSeed: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
await DownloadManager.cancelDownload(gameId);
|
await DownloadManager.pauseSeeding(gameId);
|
||||||
};
|
};
|
||||||
|
|
||||||
registerEvent("pauseGameSeed", pauseGameSeed);
|
registerEvent("pauseGameSeed", pauseGameSeed);
|
||||||
|
@ -22,7 +22,7 @@ const resumeGameSeed = async (
|
|||||||
shouldSeed: true,
|
shouldSeed: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
await DownloadManager.startDownload(game);
|
await DownloadManager.resumeSeeding(game);
|
||||||
};
|
};
|
||||||
|
|
||||||
registerEvent("resumeGameSeed", resumeGameSeed);
|
registerEvent("resumeGameSeed", resumeGameSeed);
|
||||||
|
@ -19,6 +19,7 @@ import { calculateETA, getDirSize } from "./helpers";
|
|||||||
import { QueryDeepPartialEntity } from "typeorm/query-builder/QueryPartialEntity";
|
import { QueryDeepPartialEntity } from "typeorm/query-builder/QueryPartialEntity";
|
||||||
import { RealDebridClient } from "./real-debrid";
|
import { RealDebridClient } from "./real-debrid";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
|
import { logger } from "../logger";
|
||||||
|
|
||||||
export class DownloadManager {
|
export class DownloadManager {
|
||||||
private static downloadingGameId: number | null = null;
|
private static downloadingGameId: number | null = null;
|
||||||
@ -164,6 +165,8 @@ export class DownloadManager {
|
|||||||
|
|
||||||
if (!seedStatus.length) return;
|
if (!seedStatus.length) return;
|
||||||
|
|
||||||
|
logger.log(seedStatus);
|
||||||
|
|
||||||
seedStatus.forEach(async (status) => {
|
seedStatus.forEach(async (status) => {
|
||||||
const game = await gameRepository.findOne({
|
const game = await gameRepository.findOne({
|
||||||
where: { id: status.gameId },
|
where: { id: status.gameId },
|
||||||
@ -172,7 +175,7 @@ export class DownloadManager {
|
|||||||
if (!game) return;
|
if (!game) return;
|
||||||
|
|
||||||
const totalSize = await getDirSize(
|
const totalSize = await getDirSize(
|
||||||
path.join(game.downloadPath!, status.folderName!)
|
path.join(game.downloadPath!, status.folderName)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (totalSize < status.fileSize) {
|
if (totalSize < status.fileSize) {
|
||||||
@ -219,6 +222,22 @@ export class DownloadManager {
|
|||||||
this.downloadingGameId = null;
|
this.downloadingGameId = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static async resumeSeeding(game: Game) {
|
||||||
|
await PythonRPC.rpc.post("/action", {
|
||||||
|
action: "resume_seeding",
|
||||||
|
game_id: game.id,
|
||||||
|
url: game.uri,
|
||||||
|
save_path: game.downloadPath,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
static async pauseSeeding(gameId: number) {
|
||||||
|
await PythonRPC.rpc.post("/action", {
|
||||||
|
action: "pause_seeding",
|
||||||
|
game_id: gameId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
static async startDownload(game: Game) {
|
static async startDownload(game: Game) {
|
||||||
switch (game.downloader) {
|
switch (game.downloader) {
|
||||||
case Downloader.Gofile: {
|
case Downloader.Gofile: {
|
||||||
|
@ -9,7 +9,7 @@ import type {
|
|||||||
|
|
||||||
export class RealDebridClient {
|
export class RealDebridClient {
|
||||||
private static instance: AxiosInstance;
|
private static instance: AxiosInstance;
|
||||||
private static baseURL = "https://api.real-debrid.com/rest/1.0";
|
private static readonly baseURL = "https://api.real-debrid.com/rest/1.0";
|
||||||
|
|
||||||
static authorize(apiToken: string) {
|
static authorize(apiToken: string) {
|
||||||
this.instance = axios.create({
|
this.instance = axios.create({
|
||||||
|
@ -10,7 +10,7 @@ import { logger } from "../logger";
|
|||||||
|
|
||||||
export class TorBoxClient {
|
export class TorBoxClient {
|
||||||
private static instance: AxiosInstance;
|
private static instance: AxiosInstance;
|
||||||
private static baseURL = "https://api.torbox.app/v1/api";
|
private static readonly baseURL = "https://api.torbox.app/v1/api";
|
||||||
public static apiToken: string;
|
public static apiToken: string;
|
||||||
|
|
||||||
static authorize(apiToken: string) {
|
static authorize(apiToken: string) {
|
||||||
|
@ -28,7 +28,7 @@ export class PythonRPC {
|
|||||||
|
|
||||||
private static pythonProcess: cp.ChildProcess | null = null;
|
private static pythonProcess: cp.ChildProcess | null = null;
|
||||||
|
|
||||||
public static rpc = axios.create({
|
public static readonly rpc = axios.create({
|
||||||
baseURL: `http://localhost:${this.RPC_PORT}`,
|
baseURL: `http://localhost:${this.RPC_PORT}`,
|
||||||
headers: {
|
headers: {
|
||||||
"x-hydra-rpc-password": this.RPC_PASSWORD,
|
"x-hydra-rpc-password": this.RPC_PASSWORD,
|
||||||
|
Loading…
Reference in New Issue
Block a user