Fixed: Qbittorrent ETA and Initial State

Co-Authored-By: Mark McDowall <markus101@users.noreply.github.com>
Co-Authored-By: taloth <taloth@users.noreply.github.com>
This commit is contained in:
Qstick 2018-05-19 22:38:58 -04:00
parent 570a23e143
commit 4dfe7cede4
4 changed files with 18 additions and 5 deletions

View File

@ -90,6 +90,7 @@
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.Numerics" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />

View File

@ -84,7 +84,7 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent
_logger.Warn(ex, "Failed to set the torrent priority for {0}.", filename); _logger.Warn(ex, "Failed to set the torrent priority for {0}.", filename);
} }
SetInitialState(hash); SetInitialState(hash.ToLower());
return hash; return hash;
} }
@ -107,7 +107,7 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent
item.TotalSize = torrent.Size; item.TotalSize = torrent.Size;
item.DownloadClient = Definition.Name; item.DownloadClient = Definition.Name;
item.RemainingSize = (long)(torrent.Size * (1.0 - torrent.Progress)); item.RemainingSize = (long)(torrent.Size * (1.0 - torrent.Progress));
item.RemainingTime = TimeSpan.FromSeconds(torrent.Eta); item.RemainingTime = GetRemainingTime(torrent);
item.OutputPath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(torrent.SavePath)); item.OutputPath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(torrent.SavePath));
@ -333,5 +333,15 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent
_logger.Warn(ex, "Failed to set inital state for {0}.", hash); _logger.Warn(ex, "Failed to set inital state for {0}.", hash);
} }
} }
protected TimeSpan? GetRemainingTime(QBittorrentTorrent torrent)
{
if (torrent.Eta < 0 || torrent.Eta > 365 * 24 * 3600)
{
return null;
}
return TimeSpan.FromSeconds((int)torrent.Eta);
}
} }
} }

View File

@ -1,4 +1,5 @@
using Newtonsoft.Json; using System.Numerics;
using Newtonsoft.Json;
namespace NzbDrone.Core.Download.Clients.QBittorrent namespace NzbDrone.Core.Download.Clients.QBittorrent
{ {
@ -13,7 +14,7 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent
public double Progress { get; set; } // Torrent progress (%/100) public double Progress { get; set; } // Torrent progress (%/100)
public ulong Eta { get; set; } // Torrent ETA (seconds) public BigInteger Eta { get; set; } // Torrent ETA (seconds)
public string State { get; set; } // Torrent state. See possible values here below public string State { get; set; } // Torrent state. See possible values here below

View File

@ -100,6 +100,7 @@
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.Numerics" />
<Reference Include="System.Web" /> <Reference Include="System.Web" />
<Reference Include="System.Web.Extensions" /> <Reference Include="System.Web.Extensions" />
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" />