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

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) {