fix: adding real debrid real time tracking

This commit is contained in:
Chubby Granny Chaser 2024-07-02 15:38:36 +01:00
parent a39082d326
commit 1cc5a5b209
No known key found for this signature in database
3 changed files with 1530 additions and 807 deletions

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,7 @@ import {
defineConfig,
loadEnv,
swcPlugin,
externalizeDepsPlugin
externalizeDepsPlugin,
} from "electron-vite";
import react from "@vitejs/plugin-react";
import { sentryVitePlugin } from "@sentry/vite-plugin";
@ -13,7 +13,7 @@ import svgr from "vite-plugin-svgr";
var sentryPlugin = sentryVitePlugin({
authToken: process.env.SENTRY_AUTH_TOKEN,
org: "hydra-launcher",
project: "hydra-launcher"
project: "hydra-launcher",
});
var electron_vite_config_default = defineConfig(({ mode }) => {
loadEnv(mode);
@ -22,37 +22,35 @@ var electron_vite_config_default = defineConfig(({ mode }) => {
build: {
sourcemap: true,
rollupOptions: {
external: ["better-sqlite3"]
}
external: ["better-sqlite3"],
},
},
resolve: {
alias: {
"@main": resolve("src/main"),
"@locales": resolve("src/locales"),
"@resources": resolve("resources"),
"@shared": resolve("src/shared")
}
"@shared": resolve("src/shared"),
},
plugins: [externalizeDepsPlugin(), swcPlugin(), sentryPlugin]
},
plugins: [externalizeDepsPlugin(), swcPlugin(), sentryPlugin],
},
preload: {
plugins: [externalizeDepsPlugin()]
plugins: [externalizeDepsPlugin()],
},
renderer: {
build: {
sourcemap: true
sourcemap: true,
},
resolve: {
alias: {
"@renderer": resolve("src/renderer/src"),
"@locales": resolve("src/locales"),
"@shared": resolve("src/shared")
}
"@shared": resolve("src/shared"),
},
},
plugins: [svgr(), react(), vanillaExtractPlugin(), sentryPlugin],
},
plugins: [svgr(), react(), vanillaExtractPlugin(), sentryPlugin]
}
};
});
export {
electron_vite_config_default as default
};
export { electron_vite_config_default as default };

View File

@ -51,6 +51,10 @@ export class RealDebridDownloader {
}
);
if (progress === 1) {
await this.pauseDownload();
}
return {
numPeers: 0,
numSeeds: 0,
@ -67,13 +71,42 @@ export class RealDebridDownloader {
} as DownloadProgress;
}
if (this.realDebridTorrentId && this.downloadingGame) {
const torrentInfo = await RealDebridClient.getTorrentInfo(
this.realDebridTorrentId
);
const { status } = torrentInfo;
if (status === "downloaded") {
this.startDownload(this.downloadingGame);
}
const progress = torrentInfo.progress / 100;
const totalDownloaded = progress * torrentInfo.bytes;
return {
numPeers: 0,
numSeeds: torrentInfo.seeders,
downloadSpeed: torrentInfo.speed,
timeRemaining: calculateETA(
torrentInfo.bytes,
totalDownloaded,
torrentInfo.speed
),
isDownloadingMetadata: status === "magnet_conversion",
} as DownloadProgress;
}
return null;
}
static async pauseDownload() {
HttpDownload.pauseDownload();
await HttpDownload.pauseDownload();
this.realDebridTorrentId = null;
this.downloadingGame = null;
this.downloads.delete(this.downloadingGame!.id!);
}
static async startDownload(game: Game) {