예제 #1
0
        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;
        }
예제 #2
0
        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));
        }
예제 #3
0
        public TorznabCapabilities GetCapabilities(TorznabSettings indexerSettings)
        {
            var key = indexerSettings.ToJson();
            var capabilities = _capabilitiesCache.Get(key, () => FetchCapabilities(indexerSettings), TimeSpan.FromDays(7));

            return capabilities;
        }
예제 #4
0
        public void doesnt_requires_apikey(string url)
        {
            var setting = new TorznabSettings()
            {
                ApiKey = "",
                Url = url
            };

            setting.Validate().IsValid.Should().BeTrue();
        }
예제 #5
0
        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();
        }
예제 #6
0
        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");
        }
예제 #7
0
        public void doesnt_requires_apikey(string url)
        {
            var setting = new TorznabSettings()
            {
                ApiKey = "",
                Url    = url
            };


            setting.Validate().IsValid.Should().BeTrue();
        }
예제 #8
0
        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");
        }
예제 #9
0
        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");
        }
예제 #10
0
        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");
        }
예제 #11
0
        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);
        }