private TorznabCapabilities FetchCapabilities(TorznabSettings indexerSettings) { var capabilities = new TorznabCapabilities(); var url = string.Format("{0}/api?t=caps", indexerSettings.Url.TrimEnd('/')); if (indexerSettings.ApiKey.IsNotNullOrWhiteSpace()) { url += "&apikey=" + indexerSettings.ApiKey; } var request = new HttpRequest(url, HttpAccept.Rss); try { var response = _httpClient.Get(request); capabilities = ParseCapabilities(response); } catch (Exception ex) { _logger.DebugException(string.Format("Failed to get capabilities from {0}: {1}", indexerSettings.Url, ex.Message), ex); } return capabilities; }
public void should_return_discography_time_for_discography_packs() { var settings = new TorznabSettings(); settings.SeedCriteria.DiscographySeedTime = 10; Mocker.GetMock <IIndexerFactory>() .Setup(v => v.Get(It.IsAny <int>())) .Returns(new IndexerDefinition { Settings = settings }); var result = Subject.GetSeedConfiguration(new RemoteBook { Release = new ReleaseInfo() { DownloadProtocol = DownloadProtocol.Torrent, IndexerId = 1 }, ParsedBookInfo = new ParsedBookInfo { Discography = true } }); result.Should().NotBeNull(); result.SeedTime.Should().Be(TimeSpan.FromMinutes(10)); }
public TorznabCapabilities GetCapabilities(TorznabSettings indexerSettings) { var key = indexerSettings.ToJson(); var capabilities = _capabilitiesCache.Get(key, () => FetchCapabilities(indexerSettings), TimeSpan.FromDays(7)); return capabilities; }
public void doesnt_requires_apikey(string url) { var setting = new TorznabSettings() { ApiKey = "", Url = url }; setting.Validate().IsValid.Should().BeTrue(); }
public void url_and_api_not_jackett_all(string baseUrl, string apiPath) { var setting = new TorznabSettings() { BaseUrl = baseUrl, ApiPath = apiPath }; setting.Validate().IsValid.Should().BeTrue(); }
public void requires_apikey(string url) { var setting = new TorznabSettings() { ApiKey = "", Url = url }; setting.Validate().IsValid.Should().BeFalse(); setting.Validate().Errors.Should().Contain(c => c.PropertyName == "ApiKey"); }
public void invalid_url_should_not_apikey(string url) { var setting = new TorznabSettings { ApiKey = "", Url = url }; setting.Validate().IsValid.Should().BeFalse(); setting.Validate().Errors.Should().NotContain(c => c.PropertyName == "ApiKey"); setting.Validate().Errors.Should().Contain(c => c.PropertyName == "Url"); }
private void GivenIndexer(string baseUrl, string apiPath) { var torznabSettings = new TorznabSettings { BaseUrl = baseUrl, ApiPath = apiPath }; _definition = new IndexerDefinition { Name = "Indexer", ConfigContract = "TorznabSettings", Settings = torznabSettings }; _indexers.Add(_definition); }