Ejemplo n.º 1
0
        private NewznabCapabilities FetchCapabilities(NewznabSettings indexerSettings)
        {
            var capabilities = new NewznabCapabilities();

            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;
        }
Ejemplo n.º 2
0
        public NewznabCapabilities GetCapabilities(NewznabSettings indexerSettings)
        {
            var key = indexerSettings.ToJson();
            var capabilities = _capabilitiesCache.Get(key, () => FetchCapabilities(indexerSettings), TimeSpan.FromDays(7));

            return capabilities;
        }
Ejemplo n.º 3
0
        public void SetUp()
        {
            _settings = new NewznabSettings()
            {
                BaseUrl = "http://indxer.local"
            };

            _caps = ReadAllText("Files/Indexers/Newznab/newznab_caps.xml");
        }
Ejemplo n.º 4
0
        public void SetUp()
        {
            _settings = new NewznabSettings()
            {
                Url = "http://indxer.local"
            };

            _caps = ReadAllText("Files", "Indexers", "Newznab", "newznab_caps.xml");
        }
Ejemplo n.º 5
0
        public void doesnt_requires_apikey(string url)
        {
            var setting = new NewznabSettings()
            {
                ApiKey  = "",
                BaseUrl = url
            };

            setting.Validate().IsValid.Should().BeTrue();
        }
Ejemplo n.º 6
0
        public void requires_apikey(string url)
        {
            var setting = new NewznabSettings()
            {
                ApiKey  = "",
                BaseUrl = url
            };

            setting.Validate().IsValid.Should().BeFalse();
            setting.Validate().Errors.Should().Contain(c => c.PropertyName == "ApiKey");
        }
Ejemplo n.º 7
0
        public void doesnt_requires_apikey(string url)
        {
            var setting = new NewznabSettings()
            {
                ApiKey = "",
                Url = url
            };


            setting.Validate().IsValid.Should().BeTrue();
        }
Ejemplo n.º 8
0
        public void invalid_url_should_not_apikey(string url)
        {
            var setting = new NewznabSettings
            {
                ApiKey  = "",
                BaseUrl = url
            };

            setting.Validate().IsValid.Should().BeFalse();
            setting.Validate().Errors.Should().NotContain(c => c.PropertyName == "ApiKey");
            setting.Validate().Errors.Should().Contain(c => c.PropertyName == "BaseUrl");
        }
Ejemplo n.º 9
0
        public void requires_apikey(string url)
        {
            var setting = new NewznabSettings()
            {
                ApiKey = "",
                Url = url
            };


            setting.Validate().IsValid.Should().BeFalse();
            setting.Validate().Errors.Should().Contain(c => c.PropertyName == "ApiKey");

        }
Ejemplo n.º 10
0
        public void invalid_url_should_not_apikey(string url)
        {
            var setting = new NewznabSettings
            {
                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");

        }
Ejemplo n.º 11
0
        public void SetUp()
        {
            _settings = new NewznabSettings()
            {
                BaseUrl = "http://indxer.local"
            };

            _definition = new IndexerDefinition()
            {
                Id       = 5,
                Name     = "Newznab",
                Settings = new NewznabSettings()
                {
                    BaseUrl = "http://indexer.local/"
                }
            };

            _caps = ReadAllText("Files/Indexers/Newznab/newznab_caps.xml");
        }