protected override string AddFromMagnetLink(RemoteEpisode remoteEpisode, string hash, string magnetLink) { var actualHash = _proxy.AddTorrentFromMagnet(magnetLink, Settings); if (actualHash.IsNullOrWhiteSpace()) { throw new DownloadClientException("Deluge failed to add magnet " + magnetLink); } if (!Settings.TvCategory.IsNullOrWhiteSpace()) { _proxy.SetLabel(actualHash, Settings.TvCategory, Settings); } _proxy.SetTorrentSeedingConfiguration(actualHash, remoteEpisode.SeedConfiguration, Settings); var isRecentEpisode = remoteEpisode.IsRecentEpisode(); if (isRecentEpisode && Settings.RecentTvPriority == (int)DelugePriority.First || !isRecentEpisode && Settings.OlderTvPriority == (int)DelugePriority.First) { _proxy.MoveTorrentToTopInQueue(actualHash, Settings); } return(actualHash.ToUpper()); }
protected override string AddFromTorrentFile(RemoteEpisode remoteEpisode, string hash, string filename, Byte[] fileContent) { Proxy.AddTorrentFromFile(filename, fileContent, Settings); try { var isRecentEpisode = remoteEpisode.IsRecentEpisode(); if (isRecentEpisode && Settings.RecentTvPriority == (int)QBittorrentPriority.First || !isRecentEpisode && Settings.OlderTvPriority == (int)QBittorrentPriority.First) { Proxy.MoveTorrentToTopInQueue(hash.ToLower(), Settings); } } catch (Exception ex) { _logger.Warn(ex, "Failed to set the torrent priority for {0}.", filename); } SetInitialState(hash.ToLower()); if (remoteEpisode.SeedConfiguration != null && (remoteEpisode.SeedConfiguration.Ratio.HasValue || remoteEpisode.SeedConfiguration.SeedTime.HasValue)) { Proxy.SetTorrentSeedingConfiguration(hash.ToLower(), remoteEpisode.SeedConfiguration, Settings); } return(hash); }
protected override string AddFromTorrentFile(RemoteEpisode remoteEpisode, string hash, string filename, byte[] fileContent) { var actualHash = _proxy.AddTorrentFromFile(filename, fileContent, Settings); if (actualHash.IsNullOrWhiteSpace()) { throw new DownloadClientException("Deluge failed to add torrent " + filename); } _proxy.SetTorrentSeedingConfiguration(actualHash, remoteEpisode.SeedConfiguration, Settings); if (Settings.TvCategory.IsNotNullOrWhiteSpace()) { _proxy.SetTorrentLabel(actualHash, Settings.TvCategory, Settings); } var isRecentEpisode = remoteEpisode.IsRecentEpisode(); if (isRecentEpisode && Settings.RecentTvPriority == (int)DelugePriority.First || !isRecentEpisode && Settings.OlderTvPriority == (int)DelugePriority.First) { _proxy.MoveTorrentToTopInQueue(actualHash, Settings); } return(actualHash.ToUpper()); }
protected override string AddFromTorrentFile(RemoteEpisode remoteEpisode, string hash, string filename, Byte[] fileContent) { _proxy.AddTorrentFromFile(filename, fileContent, Settings); try { if (Settings.TvCategory.IsNotNullOrWhiteSpace()) { _proxy.SetTorrentLabel(hash.ToLower(), Settings.TvCategory, Settings); } } catch (Exception ex) { _logger.Warn(ex, "Failed to set the torrent label for {0}.", filename); } try { var isRecentEpisode = remoteEpisode.IsRecentEpisode(); if (isRecentEpisode && Settings.RecentTvPriority == (int)QBittorrentPriority.First || !isRecentEpisode && Settings.OlderTvPriority == (int)QBittorrentPriority.First) { _proxy.MoveTorrentToTopInQueue(hash.ToLower(), Settings); } } catch (Exception ex) { _logger.Warn(ex, "Failed to set the torrent priority for {0}.", filename); } return(hash); }
protected override string AddFromMagnetLink(RemoteEpisode remoteEpisode, string hash, string magnetLink) { if (!Proxy.GetConfig(Settings).DhtEnabled&& !magnetLink.Contains("&tr=")) { throw new NotSupportedException("Magnet Links without trackers not supported if DHT is disabled"); } Proxy.AddTorrentFromUrl(magnetLink, Settings); var isRecentEpisode = remoteEpisode.IsRecentEpisode(); if (isRecentEpisode && Settings.RecentTvPriority == (int)QBittorrentPriority.First || !isRecentEpisode && Settings.OlderTvPriority == (int)QBittorrentPriority.First) { Proxy.MoveTorrentToTopInQueue(hash.ToLower(), Settings); } SetInitialState(hash.ToLower()); if (remoteEpisode.SeedConfiguration != null && (remoteEpisode.SeedConfiguration.Ratio.HasValue || remoteEpisode.SeedConfiguration.SeedTime.HasValue)) { Proxy.SetTorrentSeedingConfiguration(hash.ToLower(), remoteEpisode.SeedConfiguration, Settings); } return(hash); }
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 AddFromNzbFile(RemoteEpisode remoteEpisode, string filename, byte[] fileContent) { var category = Settings.TvCategory; var priority = remoteEpisode.IsRecentEpisode() ? Settings.RecentTvPriority : Settings.OlderTvPriority; var response = _proxy.DownloadNzb(fileContent, filename, category, priority, Settings); return(response); }
protected override string AddFromTorrentFile(RemoteEpisode remoteEpisode, string hash, string filename, Byte[] fileContent) { var setShareLimits = remoteEpisode.SeedConfiguration != null && (remoteEpisode.SeedConfiguration.Ratio.HasValue || remoteEpisode.SeedConfiguration.SeedTime.HasValue); var addHasSetShareLimits = setShareLimits && ProxyApiVersion >= new Version(2, 8, 1); var isRecentEpisode = remoteEpisode.IsRecentEpisode(); var moveToTop = (isRecentEpisode && Settings.RecentTvPriority == (int)QBittorrentPriority.First || !isRecentEpisode && Settings.OlderTvPriority == (int)QBittorrentPriority.First); var forceStart = (QBittorrentState)Settings.InitialState == QBittorrentState.ForceStart; Proxy.AddTorrentFromFile(filename, fileContent, addHasSetShareLimits ? remoteEpisode.SeedConfiguration : null, Settings); if (!addHasSetShareLimits && setShareLimits || moveToTop || forceStart) { if (!WaitForTorrent(hash)) { return(hash); } if (!addHasSetShareLimits && setShareLimits) { try { Proxy.SetTorrentSeedingConfiguration(hash.ToLower(), remoteEpisode.SeedConfiguration, Settings); } catch (Exception ex) { _logger.Warn(ex, "Failed to set the torrent seed criteria for {0}.", hash); } } if (moveToTop) { try { Proxy.MoveTorrentToTopInQueue(hash.ToLower(), Settings); } catch (Exception ex) { _logger.Warn(ex, "Failed to set the torrent priority for {0}.", hash); } } if (forceStart) { try { Proxy.SetForceStart(hash.ToLower(), true, Settings); } catch (Exception ex) { _logger.Warn(ex, "Failed to set ForceStart for {0}.", hash); } } } return(hash); }
protected override string AddFromNzbFile(RemoteEpisode remoteEpisode, string filename, byte[] fileContent) { var priority = remoteEpisode.IsRecentEpisode() ? Settings.RecentTvPriority : Settings.OlderTvPriority; var response = _proxy.DownloadNzb(fileContent, filename, priority, Settings); if (response == null) { throw new DownloadClientException("Failed to add nzb {0}", filename); } return(response); }
protected override string AddFromMagnetLink(RemoteEpisode remoteEpisode, string hash, string magnetLink) { _proxy.AddTorrentFromUrl(magnetLink, GetDownloadDirectory(), Settings); var isRecentEpisode = remoteEpisode.IsRecentEpisode(); if (isRecentEpisode && Settings.RecentTvPriority == (int)TransmissionPriority.First || !isRecentEpisode && Settings.OlderTvPriority == (int)TransmissionPriority.First) { _proxy.MoveTorrentToTopInQueue(hash, Settings); } return(hash); }
protected override string AddFromNzbFile(RemoteEpisode remoteEpisode, string filename, byte[] fileContent) { var category = Settings.TvCategory; var priority = remoteEpisode.IsRecentEpisode() ? Settings.RecentTvPriority : Settings.OlderTvPriority; var addpaused = Settings.AddPaused; var response = _proxy.DownloadNzb(fileContent, filename, category, priority, addpaused, Settings); if (response == null) { throw new DownloadClientRejectedReleaseException(remoteEpisode.Release, "NZBGet rejected the NZB for an unknown reason"); } return(response); }
protected override string AddFromTorrentFile(RemoteEpisode remoteEpisode, string hash, string filename, byte[] fileContent) { _proxy.AddTorrentFromData(fileContent, GetDownloadDirectory(), Settings); var isRecentEpisode = remoteEpisode.IsRecentEpisode(); if (isRecentEpisode && Settings.RecentTvPriority == (int)TransmissionPriority.First || !isRecentEpisode && Settings.OlderTvPriority == (int)TransmissionPriority.First) { _proxy.MoveTorrentToTopInQueue(hash, Settings); } return(hash); }
protected override string AddFromMagnetLink(RemoteEpisode remoteEpisode, string hash, string magnetLink) { _proxy.AddTorrentFromUrl(magnetLink, Settings); _proxy.SetTorrentLabel(hash, Settings.TvCategory, Settings); var isRecentEpisode = remoteEpisode.IsRecentEpisode(); if (isRecentEpisode && Settings.RecentTvPriority == (int)UTorrentPriority.First || !isRecentEpisode && Settings.OlderTvPriority == (int)UTorrentPriority.First) { _proxy.MoveTorrentToTopInQueue(hash, Settings); } return(hash); }
protected override string AddFromTorrentFile(RemoteEpisode remoteEpisode, string hash, string filename, byte[] fileContent) { _proxy.AddTorrentFromFile(filename, fileContent, Settings); _proxy.SetTorrentLabel(hash, Settings.TvCategory, Settings); var isRecentEpisode = remoteEpisode.IsRecentEpisode(); if (isRecentEpisode && Settings.RecentTvPriority == (int)UTorrentPriority.First || !isRecentEpisode && Settings.OlderTvPriority == (int)UTorrentPriority.First) { _proxy.MoveTorrentToTopInQueue(hash, Settings); } return(hash); }
protected override string AddFromNzbFile(RemoteEpisode remoteEpisode, string filename, byte[] fileContent) { var title = remoteEpisode.Release.Title; var category = Settings.TvCategory; var priority = remoteEpisode.IsRecentEpisode() ? Settings.RecentTvPriority : Settings.OlderTvPriority; var response = _proxy.DownloadNzb(fileContent, title, category, priority, Settings); if (response != null && response.Ids.Any()) { return(response.Ids.First()); } return(null); }
protected override string AddFromTorrentFile(RemoteEpisode remoteEpisode, string hash, string filename, byte[] fileContent) { var priority = (RTorrentPriority)(remoteEpisode.IsRecentEpisode() ? Settings.RecentTvPriority : Settings.OlderTvPriority); _proxy.AddTorrentFromFile(filename, fileContent, Settings.TvCategory, priority, Settings.TvDirectory, Settings); var tries = 10; var retryDelay = 500; if (!WaitForTorrent(hash, tries, retryDelay)) { _logger.Debug("rTorrent didn't add the torrent within {0} seconds: {1}.", tries * retryDelay / 1000, filename); throw new ReleaseDownloadException(remoteEpisode.Release, "Downloading torrent failed"); } return(hash); }
public override string DownloadNzb(RemoteEpisode remoteEpisode) { var url = remoteEpisode.Release.DownloadUrl; var title = remoteEpisode.Release.Title + ".nzb"; string category = Settings.TvCategory; int priority = remoteEpisode.IsRecentEpisode() ? Settings.RecentTvPriority : Settings.OlderTvPriority; _logger.Info("Adding report [{0}] to the queue.", title); using (var nzb = _httpProvider.DownloadStream(url)) { _logger.Info("Adding report [{0}] to the queue.", title); var response = _proxy.DownloadNzb(nzb, title, category, priority, Settings); return(response); } }
protected override string AddFromMagnetLink(RemoteEpisode remoteEpisode, string hash, string magnetLink) { var actualHash = _proxy.AddTorrentFromMagnet(magnetLink, Settings); if (!Settings.TvCategory.IsNullOrWhiteSpace()) { _proxy.SetLabel(actualHash, Settings.TvCategory, Settings); } var isRecentEpisode = remoteEpisode.IsRecentEpisode(); if (isRecentEpisode && Settings.RecentTvPriority == (int)DelugePriority.First || !isRecentEpisode && Settings.OlderTvPriority == (int)DelugePriority.First) { _proxy.MoveTorrentToTopInQueue(actualHash, Settings); } return(actualHash.ToUpper()); }
protected override string AddFromMagnetLink(RemoteEpisode remoteEpisode, string hash, string magnetLink) { var priority = (RTorrentPriority)(remoteEpisode.IsRecentEpisode() ? Settings.RecentTvPriority : Settings.OlderTvPriority); _proxy.AddTorrentFromUrl(magnetLink, Settings.TvCategory, priority, Settings.TvDirectory, 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 AddFromTorrentFile(RemoteEpisode remoteEpisode, string hash, string filename, Byte[] fileContent) { _proxy.AddTorrentFromFile(filename, fileContent, Settings); if (Settings.TvCategory.IsNotNullOrWhiteSpace()) { _proxy.SetTorrentLabel(hash.ToLower(), Settings.TvCategory, Settings); } var isRecentEpisode = remoteEpisode.IsRecentEpisode(); if (isRecentEpisode && Settings.RecentTvPriority == (int)QBittorrentPriority.First || !isRecentEpisode && Settings.OlderTvPriority == (int)QBittorrentPriority.First) { _proxy.MoveTorrentToTopInQueue(hash.ToLower(), Settings); } return(hash); }
public override string DownloadNzb(RemoteEpisode remoteEpisode) { var url = remoteEpisode.Release.DownloadUrl; var title = remoteEpisode.Release.Title; var category = Settings.TvCategory; var priority = remoteEpisode.IsRecentEpisode() ? Settings.RecentTvPriority : Settings.OlderTvPriority; using (var nzb = _httpProvider.DownloadStream(url)) { _logger.Info("Adding report [{0}] to the queue.", title); var response = _proxy.DownloadNzb(nzb, title, category, priority, Settings); if (response != null && response.Ids.Any()) { return(response.Ids.First()); } return(null); } }
protected override string AddFromTorrentFile(RemoteEpisode remoteEpisode, string hash, string filename, byte[] fileContent) { var actualHash = _proxy.AddTorrentFromFile(filename, fileContent, Settings); if (!Settings.TvCategory.IsNullOrWhiteSpace()) { _proxy.SetLabel(actualHash, Settings.TvCategory, Settings); } _proxy.SetTorrentConfiguration(actualHash, "remove_at_ratio", false, Settings); var isRecentEpisode = remoteEpisode.IsRecentEpisode(); if (isRecentEpisode && Settings.RecentTvPriority == (int)DelugePriority.First || !isRecentEpisode && Settings.OlderTvPriority == (int)DelugePriority.First) { _proxy.MoveTorrentToTopInQueue(actualHash, Settings); } return(actualHash.ToUpper()); }
protected override string AddFromMagnetLink(RemoteEpisode remoteEpisode, string hash, string magnetLink) { _proxy.AddTorrentFromUrl(magnetLink, Settings); if (Settings.TvCategory.IsNotNullOrWhiteSpace()) { _proxy.SetTorrentLabel(hash.ToLower(), Settings.TvCategory, Settings); } var isRecentEpisode = remoteEpisode.IsRecentEpisode(); if (isRecentEpisode && Settings.RecentTvPriority == (int)QBittorrentPriority.First || !isRecentEpisode && Settings.OlderTvPriority == (int)QBittorrentPriority.First) { _proxy.MoveTorrentToTopInQueue(hash.ToLower(), Settings); } SetInitialState(hash.ToLower()); return(hash); }
protected override string AddFromTorrentFile(RemoteEpisode remoteEpisode, string hash, string filename, byte[] fileContent) { _proxy.AddTorrentFromFile(filename, fileContent, Settings); _proxy.SetTorrentSeedingConfiguration(hash, remoteEpisode.SeedConfiguration, Settings); if (Settings.TvCategory.IsNotNullOrWhiteSpace()) { _proxy.SetTorrentLabel(hash, Settings.TvCategory, Settings); } var isRecentEpisode = remoteEpisode.IsRecentEpisode(); if (isRecentEpisode && Settings.RecentTvPriority == (int)UTorrentPriority.First || !isRecentEpisode && Settings.OlderTvPriority == (int)UTorrentPriority.First) { _proxy.MoveTorrentToTopInQueue(hash, Settings); } _proxy.SetState(hash, (UTorrentState)Settings.IntialState, Settings); return(hash); }
public void DownloadNzb(RemoteEpisode remoteEpisode) { var url = remoteEpisode.Release.DownloadUrl; var title = remoteEpisode.Release.Title + ".nzb"; string cat = _configService.NzbgetTvCategory; int priority = remoteEpisode.IsRecentEpisode() ? (int)_configService.NzbgetRecentTvPriority : (int)_configService.NzbgetOlderTvPriority; var command = new JsonRequest { Method = "appendurl", Params = new object[] { title, cat, priority, false, url } }; _logger.Info("Adding report [{0}] to the queue.", title); var response = PostCommand(command.ToJson()); CheckForError(response); var success = Json.Deserialize <EnqueueResponse>(response).Result; _logger.Debug("Queue Response: [{0}]", success); }
public void DownloadNzb(RemoteEpisode remoteEpisode) { var url = remoteEpisode.Release.DownloadUrl; var title = remoteEpisode.Release.Title; string cat = _configService.SabTvCategory; int priority = remoteEpisode.IsRecentEpisode() ? (int)_configService.SabRecentTvPriority : (int)_configService.SabOlderTvPriority; string name = url.Replace("&", "%26"); string nzbName = HttpUtility.UrlEncode(title); string action = string.Format("mode=addurl&name={0}&priority={1}&pp=3&cat={2}&nzbname={3}&output=json", name, priority, cat, nzbName); string request = GetSabRequest(action); _logger.Info("Adding report [{0}] to the queue.", title); var response = _httpProvider.DownloadString(request); _logger.Debug("Queue Response: [{0}]", response); CheckForError(response); }
protected override string AddFromMagnetLink(RemoteEpisode remoteEpisode, string hash, string magnetLink) { if (!Proxy.GetConfig(Settings).DhtEnabled&& !magnetLink.Contains("&tr=")) { throw new NotSupportedException("Magnet Links without trackers not supported if DHT is disabled"); } var setShareLimits = remoteEpisode.SeedConfiguration != null && (remoteEpisode.SeedConfiguration.Ratio.HasValue || remoteEpisode.SeedConfiguration.SeedTime.HasValue); var addHasSetShareLimits = setShareLimits && ProxyApiVersion >= new Version(2, 8, 1); var isRecentEpisode = remoteEpisode.IsRecentEpisode(); var moveToTop = (isRecentEpisode && Settings.RecentTvPriority == (int)QBittorrentPriority.First || !isRecentEpisode && Settings.OlderTvPriority == (int)QBittorrentPriority.First); var forceStart = (QBittorrentState)Settings.InitialState == QBittorrentState.ForceStart; Proxy.AddTorrentFromUrl(magnetLink, addHasSetShareLimits && setShareLimits ? remoteEpisode.SeedConfiguration : null, Settings); if (!addHasSetShareLimits && setShareLimits || moveToTop || forceStart) { if (!WaitForTorrent(hash)) { return(hash); } if (!addHasSetShareLimits && setShareLimits) { try { Proxy.SetTorrentSeedingConfiguration(hash.ToLower(), remoteEpisode.SeedConfiguration, Settings); } catch (Exception ex) { _logger.Warn(ex, "Failed to set the torrent seed criteria for {0}.", hash); } } if (moveToTop) { try { Proxy.MoveTorrentToTopInQueue(hash.ToLower(), Settings); } catch (Exception ex) { _logger.Warn(ex, "Failed to set the torrent priority for {0}.", hash); } } if (forceStart) { try { Proxy.SetForceStart(hash.ToLower(), true, Settings); } catch (Exception ex) { _logger.Warn(ex, "Failed to set ForceStart for {0}.", hash); } } } return(hash); }
private void SetPriority(RemoteEpisode remoteEpisode, string hash) { var priority = (RTorrentPriority)(remoteEpisode.IsRecentEpisode() ? Settings.RecentTvPriority : Settings.OlderTvPriority); _proxy.SetTorrentPriority(hash, priority, Settings); }