private ValidationFailure TestGetTorrents() { try { _proxy.GetTorrents(Settings); } catch (Exception ex) { _logger.Error(ex, ex.Message); return(new NzbDroneValidationFailure(string.Empty, "Failed to get the list of torrents: " + ex.Message)); } return(null); }
public override IEnumerable <DownloadClientItem> GetItems() { var torrents = _proxy.GetTorrents(Settings); var items = new List <DownloadClientItem>(); foreach (var torrent in torrents) { if (Settings.Category.IsNotNullOrWhiteSpace() && torrent.Label != Settings.Category) { continue; } var outputPath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(torrent.SavePath)); var eta = TimeSpan.FromSeconds(0); if (torrent.DownloadRate > 0 && torrent.TotalSize > 0) { eta = TimeSpan.FromSeconds(torrent.TotalSize / (double)torrent.DownloadRate); } var item = new DownloadClientItem { DownloadClientInfo = DownloadClientItemClientInfo.FromDownloadClient(this), DownloadId = torrent.InfoHash.ToUpper(), OutputPath = outputPath + torrent.Name, RemainingSize = torrent.TotalSize - torrent.DownloadedBytes, RemainingTime = eta, Title = torrent.Name, TotalSize = torrent.TotalSize, SeedRatio = torrent.DownloadedBytes <= 0 ? 0 : (double)torrent.UploadedBytes / torrent.DownloadedBytes }; if (!string.IsNullOrEmpty(torrent.Error)) { item.Status = DownloadItemStatus.Warning; item.Message = torrent.Error; } else if (torrent.IsFinished && torrent.State != HadoukenTorrentState.CheckingFiles) { item.Status = DownloadItemStatus.Completed; } else if (torrent.State == HadoukenTorrentState.QueuedForChecking) { item.Status = DownloadItemStatus.Queued; } else if (torrent.State == HadoukenTorrentState.Paused) { item.Status = DownloadItemStatus.Paused; } else { item.Status = DownloadItemStatus.Downloading; } item.CanMoveFiles = item.CanBeRemoved = (torrent.IsFinished && torrent.State == HadoukenTorrentState.Paused); items.Add(item); } return(items); }
public override IEnumerable <DownloadClientItem> GetItems() { HadoukenTorrent[] torrents; try { torrents = _proxy.GetTorrents(Settings); } catch (DownloadClientException ex) { _logger.ErrorException(ex.Message, ex); return(Enumerable.Empty <DownloadClientItem>()); } var items = new List <DownloadClientItem>(); foreach (var torrent in torrents) { if (Settings.Category.IsNotNullOrWhiteSpace() && torrent.Label != Settings.Category) { continue; } var outputPath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(torrent.SavePath)); var eta = TimeSpan.FromSeconds(0); if (torrent.DownloadRate > 0 && torrent.TotalSize > 0) { eta = TimeSpan.FromSeconds(torrent.TotalSize / (double)torrent.DownloadRate); } var item = new DownloadClientItem { DownloadClient = Definition.Name, DownloadId = torrent.InfoHash.ToUpper(), OutputPath = outputPath + torrent.Name, RemainingSize = torrent.TotalSize - torrent.DownloadedBytes, RemainingTime = eta, Title = torrent.Name, TotalSize = torrent.TotalSize }; if (!string.IsNullOrEmpty(torrent.Error)) { item.Status = DownloadItemStatus.Warning; item.Message = torrent.Error; } else if (torrent.IsFinished && torrent.State != HadoukenTorrentState.CheckingFiles) { item.Status = DownloadItemStatus.Completed; } else if (torrent.State == HadoukenTorrentState.QueuedForChecking) { item.Status = DownloadItemStatus.Queued; } else if (torrent.State == HadoukenTorrentState.Paused) { item.Status = DownloadItemStatus.Paused; } else { item.Status = DownloadItemStatus.Downloading; } if (torrent.IsFinished && torrent.State == HadoukenTorrentState.Paused) { item.IsReadOnly = false; } else { item.IsReadOnly = true; } items.Add(item); } return(items); }