private bool WaitForTorrent(string hash, int tries, int retryDelay) { for (var i = 0; i < tries; i++) { if (_proxy.HasHashTorrent(hash, Settings)) { return(true); } Thread.Sleep(retryDelay); } _logger.Debug("Could not find hash {0} in {1} tries at {2} ms intervals.", hash, tries, retryDelay); return(false); }
protected override string AddFromMagnetLink(RemoteEpisode remoteEpisode, string hash, string magnetLink) { _proxy.AddTorrentFromUrl(magnetLink, Settings); // Wait until url has been resolved before returning var TRIES = 5; var RETRY_DELAY = 500; //ms var ready = false; for (var i = 0; i < TRIES; i++) { ready = _proxy.HasHashTorrent(hash, Settings); if (ready) { break; } Thread.Sleep(RETRY_DELAY); } if (ready) { _proxy.SetTorrentLabel(hash, Settings.TvCategory, Settings); SetPriority(remoteEpisode, hash); SetDownloadDirectory(hash); _proxy.StartTorrent(hash, Settings); return(hash); } else { _logger.Debug("Magnet {0} could not be resolved in {1} tries at {2} ms intervals.", magnetLink, TRIES, RETRY_DELAY); // Remove from client, since it is discarded RemoveItem(hash, true); return(null); } }