protected override string AddFromMagnetLink(RemoteEpisode remoteEpisode, string hash, string magnetLink) { _proxy.AddTorrentFromUrl(magnetLink, Settings); // Download the magnet to the appropriate directory. _proxy.SetTorrentLabel(hash, Settings.TvCategory, Settings); SetPriority(remoteEpisode, hash); SetDownloadDirectory(hash); // Once the magnet meta download finishes, rTorrent replaces it with the actual torrent download with default settings. // Schedule an event to apply the appropriate settings when that happens. var priority = (RTorrentPriority)(remoteEpisode.IsRecentEpisode() ? Settings.RecentTvPriority : Settings.OlderTvPriority); _proxy.SetDeferredMagnetProperties(hash, Settings.TvCategory, Settings.TvDirectory, priority, Settings); _proxy.StartTorrent(hash, Settings); // Wait for the magnet to be resolved. var tries = 10; var retryDelay = 500; if (WaitForTorrent(hash, tries, retryDelay)) { return(hash); } else { _logger.Warn("rTorrent could not resolve magnet within {0} seconds, download may remain stuck: {1}.", tries * retryDelay / 1000, magnetLink); return(hash); } }
protected override string AddFromMagnetLink(RemoteEpisode remoteEpisode, string hash, string magnetLink) { _proxy.AddTorrentFromUrl(magnetLink, Settings); var tries = 10; var retryDelay = 500; if (WaitForTorrent(hash, tries, retryDelay)) { _proxy.SetTorrentLabel(hash, Settings.TvCategory, Settings); SetPriority(remoteEpisode, hash); SetDownloadDirectory(hash); _proxy.StartTorrent(hash, Settings); return(hash); } else { _logger.Debug("rTorrent could not resolve magnet {0}. Removing", magnetLink); RemoveItem(hash, true); return(null); } }
protected override string AddFromMagnetLink(RemoteMovie remoteMovie, string hash, string magnetLink) { _proxy.AddTorrentFromUrl(magnetLink, Settings.MovieCategory, RTorrentPriority.Normal, Settings.MovieDirectory, Settings); var tries = 10; var retryDelay = 500; // Wait a bit for the magnet to be resolved. if (!WaitForTorrent(hash, tries, retryDelay)) { _logger.Warn("rTorrent could not resolve magnet within {0} seconds, download may remain stuck: {1}.", tries * retryDelay / 1000, magnetLink); return(hash); } return(hash); }
protected override string AddFromMagnetLink(RemoteAlbum remoteAlbum, string hash, string magnetLink) { var priority = (RTorrentPriority)(remoteAlbum.IsRecentAlbum() ? Settings.RecentTvPriority : Settings.OlderTvPriority); _proxy.AddTorrentFromUrl(magnetLink, Settings.MusicCategory, priority, Settings.MusicDirectory, Settings); var tries = 10; var retryDelay = 500; // Wait a bit for the magnet to be resolved. if (!WaitForTorrent(hash, tries, retryDelay)) { _logger.Warn("rTorrent could not resolve magnet within {0} seconds, download may remain stuck: {1}.", tries * retryDelay / 1000, magnetLink); return(hash); } return(hash); }
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); } }