From 2ef0ddc0b70ea55998ebaeab8b3d6ec8f0837de6 Mon Sep 17 00:00:00 2001 From: Ivan Sanz Carasa Date: Thu, 28 Mar 2024 18:59:09 +0100 Subject: [PATCH 1/2] all changes --- .../RdtClient.Service/Services/QBittorrent.cs | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/server/RdtClient.Service/Services/QBittorrent.cs b/server/RdtClient.Service/Services/QBittorrent.cs index e01d360..a02b68e 100644 --- a/server/RdtClient.Service/Services/QBittorrent.cs +++ b/server/RdtClient.Service/Services/QBittorrent.cs @@ -224,8 +224,10 @@ public class QBittorrent torrentPath = Path.Combine(downloadPath, torrent.RdName) + Path.DirectorySeparatorChar; } - var bytesDone = torrent.RdProgress; + Decimal? rdProgress = torrent.RdProgress / 100.0m; + Decimal? downloadProgress = 0; var bytesTotal = torrent.RdSize; + var bytesDone = (long?)(torrent.RdSize * rdProgress); var speed = torrent.RdSpeed ?? 0; if (torrent.Downloads.Count > 0) @@ -233,14 +235,10 @@ public class QBittorrent bytesDone = torrent.Downloads.Sum(m => m.BytesDone); bytesTotal = torrent.Downloads.Sum(m => m.BytesTotal); speed = (Int32) torrent.Downloads.Average(m => m.Speed); + downloadProgress = bytesTotal > 0 ? (Decimal?)bytesDone / bytesTotal : 0; } - var progress = (bytesDone / (Single?)bytesTotal); - - if (progress == null || !Single.IsNormal(progress.Value)) - { - progress = 0; - } + Decimal? progress = (rdProgress + downloadProgress) / 2m; var result = new TorrentInfo { @@ -267,10 +265,10 @@ public class QBittorrent Name = torrent.RdName, NumComplete = 10, NumIncomplete = 0, - NumLeechs = 100, - NumSeeds = 100, + NumLeechs = 1, + NumSeeds = torrent.RdSeeders ?? 1, Priority = ++prio, - Progress = (Single) progress, + Progress = (float)(progress ?? 0), Ratio = 1, RatioLimit = 1, SavePath = downloadPath, @@ -298,6 +296,10 @@ public class QBittorrent { result.State = "pausedUP"; } + else if (torrent.RdStatus == TorrentStatus.Downloading && torrent.RdSeeders < 1) + { + result.State = "stalledDL"; + } results.Add(result); } From 716d89680dd3a7ec65f22118c201a0e85c32c7e3 Mon Sep 17 00:00:00 2001 From: Ivan Sanz Carasa Date: Fri, 29 Mar 2024 18:46:09 +0100 Subject: [PATCH 2/2] add stalled state in UI --- client/src/app/torrent-status.pipe.ts | 10 ++++++---- .../src/app/torrent-table/torrent-table.component.html | 6 +++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/client/src/app/torrent-status.pipe.ts b/client/src/app/torrent-status.pipe.ts index b2c64f6..232d3e0 100644 --- a/client/src/app/torrent-status.pipe.ts +++ b/client/src/app/torrent-status.pipe.ts @@ -6,7 +6,7 @@ import { RealDebridStatus, Torrent } from './models/torrent.model'; name: 'status', }) export class TorrentStatusPipe implements PipeTransform { - constructor(private pipe: FileSizePipe) {} + constructor(private pipe: FileSizePipe) { } transform(torrent: Torrent): string { if (torrent.error) { @@ -38,9 +38,8 @@ export class TorrentStatusPipe implements PipeTransform { speed = this.pipe.transform(allSpeeds, 'filesize'); - return `Downloading file ${downloading.length + downloaded.length}/${ - torrent.downloads.length - } (${progress.toFixed(2)}% - ${speed}/s)`; + return `Downloading file ${downloading.length + downloaded.length}/${torrent.downloads.length + } (${progress.toFixed(2)}% - ${speed}/s)`; } const unpacking = torrent.downloads.where((m) => m.unpackingStarted && !m.unpackingFinished && m.bytesDone > 0); @@ -87,6 +86,9 @@ export class TorrentStatusPipe implements PipeTransform { switch (torrent.rdStatus) { case RealDebridStatus.Downloading: + if (torrent.rdSeeders < 1) { + return `Torrent stalled` + } const speed = this.pipe.transform(torrent.rdSpeed, 'filesize'); return `Torrent downloading (${torrent.rdProgress}% - ${speed}/s)`; case RealDebridStatus.Processing: diff --git a/client/src/app/torrent-table/torrent-table.component.html b/client/src/app/torrent-table/torrent-table.component.html index bf0fab4..a85f2da 100644 --- a/client/src/app/torrent-table/torrent-table.component.html +++ b/client/src/app/torrent-table/torrent-table.component.html @@ -16,6 +16,7 @@ Name Category Priority + Seeders Files Downloads Size @@ -40,6 +41,9 @@ {{ torrent.priority }} + + {{ torrent.rdSeeders }} + {{ torrent.files.length | number }} @@ -74,7 +78,7 @@ > Retry Selected - +