|
|
|
@ -81,69 +81,60 @@ namespace NzbDrone.Core.Download.Clients.RTorrent
|
|
|
|
|
|
|
|
|
|
public override IEnumerable<DownloadClientItem> GetItems()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
var torrents = _proxy.GetTorrents(Settings);
|
|
|
|
|
|
|
|
|
|
_logger.Debug("Retrieved metadata of {0} torrents in client", torrents.Count);
|
|
|
|
|
|
|
|
|
|
var items = new List<DownloadClientItem>();
|
|
|
|
|
foreach (RTorrentTorrent torrent in torrents)
|
|
|
|
|
{
|
|
|
|
|
var torrents = _proxy.GetTorrents(Settings);
|
|
|
|
|
// Don't concern ourselves with categories other than specified
|
|
|
|
|
if (torrent.Category != Settings.TvCategory) continue;
|
|
|
|
|
|
|
|
|
|
_logger.Debug("Retrieved metadata of {0} torrents in client", torrents.Count);
|
|
|
|
|
if (torrent.Path.StartsWith("."))
|
|
|
|
|
{
|
|
|
|
|
throw new DownloadClientException("Download paths paths must be absolute. Please specify variable \"directory\" in rTorrent.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var items = new List<DownloadClientItem>();
|
|
|
|
|
foreach (RTorrentTorrent torrent in torrents)
|
|
|
|
|
var item = new DownloadClientItem();
|
|
|
|
|
item.DownloadClient = Definition.Name;
|
|
|
|
|
item.Title = torrent.Name;
|
|
|
|
|
item.DownloadId = torrent.Hash;
|
|
|
|
|
item.OutputPath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(torrent.Path));
|
|
|
|
|
item.TotalSize = torrent.TotalSize;
|
|
|
|
|
item.RemainingSize = torrent.RemainingSize;
|
|
|
|
|
item.Category = torrent.Category;
|
|
|
|
|
|
|
|
|
|
if (torrent.DownRate > 0)
|
|
|
|
|
{
|
|
|
|
|
var secondsLeft = torrent.RemainingSize / torrent.DownRate;
|
|
|
|
|
item.RemainingTime = TimeSpan.FromSeconds(secondsLeft);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Don't concern ourselves with categories other than specified
|
|
|
|
|
if (torrent.Category != Settings.TvCategory) continue;
|
|
|
|
|
|
|
|
|
|
if (torrent.Path.StartsWith("."))
|
|
|
|
|
{
|
|
|
|
|
throw new DownloadClientException("Download paths paths must be absolute. Please specify variable \"directory\" in rTorrent.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var item = new DownloadClientItem();
|
|
|
|
|
item.DownloadClient = Definition.Name;
|
|
|
|
|
item.Title = torrent.Name;
|
|
|
|
|
item.DownloadId = torrent.Hash;
|
|
|
|
|
item.OutputPath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(torrent.Path));
|
|
|
|
|
item.TotalSize = torrent.TotalSize;
|
|
|
|
|
item.RemainingSize = torrent.RemainingSize;
|
|
|
|
|
item.Category = torrent.Category;
|
|
|
|
|
|
|
|
|
|
if (torrent.DownRate > 0)
|
|
|
|
|
{
|
|
|
|
|
var secondsLeft = torrent.RemainingSize / torrent.DownRate;
|
|
|
|
|
item.RemainingTime = TimeSpan.FromSeconds(secondsLeft);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
item.RemainingTime = TimeSpan.Zero;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (torrent.IsFinished)
|
|
|
|
|
{
|
|
|
|
|
item.Status = DownloadItemStatus.Completed;
|
|
|
|
|
}
|
|
|
|
|
else if (torrent.IsActive)
|
|
|
|
|
{
|
|
|
|
|
item.Status = DownloadItemStatus.Downloading;
|
|
|
|
|
}
|
|
|
|
|
else if (!torrent.IsActive)
|
|
|
|
|
{
|
|
|
|
|
item.Status = DownloadItemStatus.Paused;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// No stop ratio data is present, so do not delete
|
|
|
|
|
item.CanMoveFiles = item.CanBeRemoved = false;
|
|
|
|
|
|
|
|
|
|
items.Add(item);
|
|
|
|
|
item.RemainingTime = TimeSpan.Zero;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return items;
|
|
|
|
|
}
|
|
|
|
|
catch (DownloadClientException ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.Error(ex, ex.Message);
|
|
|
|
|
return Enumerable.Empty<DownloadClientItem>();
|
|
|
|
|
if (torrent.IsFinished)
|
|
|
|
|
{
|
|
|
|
|
item.Status = DownloadItemStatus.Completed;
|
|
|
|
|
}
|
|
|
|
|
else if (torrent.IsActive)
|
|
|
|
|
{
|
|
|
|
|
item.Status = DownloadItemStatus.Downloading;
|
|
|
|
|
}
|
|
|
|
|
else if (!torrent.IsActive)
|
|
|
|
|
{
|
|
|
|
|
item.Status = DownloadItemStatus.Paused;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// No stop ratio data is present, so do not delete
|
|
|
|
|
item.CanMoveFiles = item.CanBeRemoved = false;
|
|
|
|
|
|
|
|
|
|
items.Add(item);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return items;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void RemoveItem(string downloadId, bool deleteData)
|
|
|
|
|