private ValidationFailure TestGetTorrents() { try { _proxy.GetTorrents(Settings); } catch (Exception ex) { _logger.Error(ex, "Failed to get torrents"); 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); _logger.Debug("Retrieved metadata of {0} torrents in client", torrents.Count); var items = new List <DownloadClientItem>(); foreach (RTorrentTorrent torrent in torrents) { // Don't concern ourselves with categories other than specified if (Settings.MusicCategory.IsNotNullOrWhiteSpace() && torrent.Category != Settings.MusicCategory) { continue; } if (torrent.Path.StartsWith(".")) { throw new DownloadClientException("Download paths must be absolute. Please specify variable \"directory\" in rTorrent."); } var item = new DownloadClientItem(); item.DownloadClientInfo = DownloadClientItemClientInfo.FromDownloadClient(this); 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; item.SeedRatio = torrent.Ratio; 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); } return(items); }
public override IEnumerable <DownloadClientItem> GetItems() { 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) { // Don't concern ourselves with categories other than specified if (Settings.TvCategory.IsNotNullOrWhiteSpace() && torrent.Category != Settings.TvCategory) { continue; } if (torrent.Path.StartsWith(".")) { throw new DownloadClientException("Download paths must be absolute. Please specify variable \"directory\" in rTorrent."); } var item = new DownloadClientItem(); item.DownloadClientInfo = DownloadClientItemClientInfo.FromDownloadClient(this); 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; item.SeedRatio = torrent.Ratio; 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; } // Grab cached seedConfig var seedConfig = _downloadSeedConfigProvider.GetSeedConfiguration(torrent.Hash); // Check if torrent is finished and if it exceeds cached seedConfig item.CanMoveFiles = item.CanBeRemoved = torrent.IsFinished && seedConfig != null && ( (torrent.Ratio / 1000.0) >= seedConfig.Ratio || (DateTimeOffset.Now - DateTimeOffset.FromUnixTimeSeconds(torrent.FinishedTime)) >= seedConfig.SeedTime ); items.Add(item); } return(items); }
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) { // 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.IsReadOnly = true; items.Add(item); } return(items); } catch (DownloadClientException ex) { _logger.Error(ex, ex.Message); return(Enumerable.Empty <DownloadClientItem>()); } }