private String GetDownloadDirectory() { if (Settings.TvCategory.IsNullOrWhiteSpace()) { return(null); } var config = _proxy.GetConfig(Settings); var destDir = (String)config.GetValueOrDefault("download-dir"); return(string.Format("{0}/{1}", destDir.TrimEnd('/'), Settings.TvCategory)); }
public override DownloadClientStatus GetStatus() { var config = _proxy.GetConfig(Settings); var destDir = config.GetValueOrDefault("download-dir") as string; if (Settings.TvCategory.IsNotNullOrWhiteSpace()) { destDir = string.Format("{0}/.{1}", destDir, Settings.TvCategory); } return(new DownloadClientStatus { IsLocalhost = Settings.Host == "127.0.0.1" || Settings.Host == "localhost", OutputRootFolders = new List <OsPath> { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(destDir)) } }); }
protected string GetDownloadDirectory() { if (Settings.Directory.IsNotNullOrWhiteSpace()) { return(Settings.Directory); } if (!Settings.Category.IsNotNullOrWhiteSpace()) { return(null); } var config = _proxy.GetConfig(Settings); var destDir = config.DownloadDir; return($"{destDir.TrimEnd('/')}/{Settings.Category}"); }
public override IEnumerable <DownloadClientItem> GetItems() { var configFunc = new Lazy <TransmissionConfig>(() => _proxy.GetConfig(Settings)); var torrents = _proxy.GetTorrents(Settings); var items = new List <DownloadClientItem>(); foreach (var torrent in torrents) { // If totalsize == 0 the torrent is a magnet downloading metadata if (torrent.TotalSize == 0) { continue; } var outputPath = new OsPath(torrent.DownloadDir); if (Settings.TvDirectory.IsNotNullOrWhiteSpace()) { if (!new OsPath(Settings.TvDirectory).Contains(outputPath)) { continue; } } else if (Settings.TvCategory.IsNotNullOrWhiteSpace()) { var directories = outputPath.FullPath.Split('\\', '/'); if (!directories.Contains(Settings.TvCategory)) { continue; } } outputPath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, outputPath); var item = new DownloadClientItem(); item.DownloadId = torrent.HashString.ToUpper(); item.Category = Settings.TvCategory; item.Title = torrent.Name; item.DownloadClientInfo = DownloadClientItemClientInfo.FromDownloadClient(this); item.OutputPath = GetOutputPath(outputPath, torrent); item.TotalSize = torrent.TotalSize; item.RemainingSize = torrent.LeftUntilDone; item.SeedRatio = torrent.DownloadedEver <= 0 ? 0 : (double)torrent.UploadedEver / torrent.DownloadedEver; if (torrent.Eta >= 0) { item.RemainingTime = TimeSpan.FromSeconds(torrent.Eta); } if (!torrent.ErrorString.IsNullOrWhiteSpace()) { item.Status = DownloadItemStatus.Warning; item.Message = torrent.ErrorString; } else if (torrent.LeftUntilDone == 0 && (torrent.Status == TransmissionTorrentStatus.Stopped || torrent.Status == TransmissionTorrentStatus.Seeding || torrent.Status == TransmissionTorrentStatus.SeedingWait)) { item.Status = DownloadItemStatus.Completed; } else if (torrent.IsFinished && torrent.Status != TransmissionTorrentStatus.Check && torrent.Status != TransmissionTorrentStatus.CheckWait) { item.Status = DownloadItemStatus.Completed; } else if (torrent.Status == TransmissionTorrentStatus.Queued) { item.Status = DownloadItemStatus.Queued; } else { item.Status = DownloadItemStatus.Downloading; } item.CanBeRemoved = HasReachedSeedLimit(torrent, item.SeedRatio, configFunc); item.CanMoveFiles = item.CanBeRemoved && torrent.Status == TransmissionTorrentStatus.Stopped; items.Add(item); } return(items); }