public NewznabCapabilities GetCapabilities(NewznabSettings indexerSettings) { var key = indexerSettings.ToJson(); var capabilities = _capabilitiesCache.Get(key, () => FetchCapabilities(indexerSettings), TimeSpan.FromDays(7)); return(capabilities); }
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); }
public IndexerCapabilities GetCapabilities(NewznabSettings indexerSettings, ProviderDefinition definition) { var key = indexerSettings.ToJson(); var capabilities = _capabilitiesCache.Get(key, () => FetchCapabilities(indexerSettings, definition), TimeSpan.FromDays(7)); return(capabilities); }
private NewznabCapabilities FetchCapabilities(NewznabSettings indexerSettings) { var capabilities = new NewznabCapabilities(); var url = string.Format("{0}{1}?t=caps", indexerSettings.BaseUrl.TrimEnd('/'), indexerSettings.ApiPath.TrimEnd('/')); if (indexerSettings.ApiKey.IsNotNullOrWhiteSpace()) { url += "&apikey=" + indexerSettings.ApiKey; } var request = new HttpRequest(url, HttpAccept.Rss); request.AllowAutoRedirect = true; HttpResponse response; try { response = _httpClient.Get(request); } catch (Exception ex) { _logger.Debug(ex, "Failed to get newznab api capabilities from {0}", indexerSettings.BaseUrl); throw; } try { capabilities = ParseCapabilities(response); } catch (XmlException ex) { ex.WithData(response, 128 * 1024); _logger.Trace("Unexpected Response content ({0} bytes): {1}", response.ResponseData.Length, response.Content); _logger.Debug(ex, "Failed to parse newznab api capabilities for {0}", indexerSettings.BaseUrl); throw; } catch (Exception ex) { ex.WithData(response, 128 * 1024); _logger.Trace("Unexpected Response content ({0} bytes): {1}", response.ResponseData.Length, response.Content); _logger.Error(ex, "Failed to determine newznab api capabilities for {0}, using the defaults instead till Sonarr restarts", indexerSettings.BaseUrl); } return(capabilities); }
private IndexerCapabilities FetchCapabilities(NewznabSettings indexerSettings, ProviderDefinition definition) { var capabilities = new IndexerCapabilities(); var url = string.Format("{0}{1}?t=caps", indexerSettings.BaseUrl.TrimEnd('/'), indexerSettings.ApiPath.TrimEnd('/')); if (indexerSettings.ApiKey.IsNotNullOrWhiteSpace()) { url += "&apikey=" + indexerSettings.ApiKey; } var request = new HttpRequest(url, HttpAccept.Rss); request.AllowAutoRedirect = true; request.Method = HttpMethod.Get; HttpResponse response; try { response = _httpClient.ExecuteProxied(request, definition); } catch (Exception ex) { _logger.Debug(ex, "Failed to get Newznab API capabilities from {0}", indexerSettings.BaseUrl); throw; } try { capabilities = ParseCapabilities(response); } catch (XmlException ex) { ex.WithData(response, 128 * 1024); _logger.Trace("Unexpected Response content ({0} bytes): {1}", response.ResponseData.Length, response.Content); _logger.Debug(ex, "Failed to parse newznab api capabilities for {0}", indexerSettings.BaseUrl); throw; } catch (Exception ex) { ex.WithData(response, 128 * 1024); _logger.Trace("Unexpected Response content ({0} bytes): {1}", response.ResponseData.Length, response.Content); } return(capabilities); }
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); HttpResponse response; try { response = _httpClient.Get(request); } catch (Exception ex) { _logger.Debug(ex, "Failed to get newznab api capabilities from {0}", indexerSettings.Url); throw; } try { capabilities = ParseCapabilities(response); } catch (XmlException ex) { _logger.Debug(ex, "Failed to parse newznab api capabilities for {0}.", indexerSettings.Url); ex.WithData(response); throw; } catch (Exception ex) { _logger.Error(ex, "Failed to determine newznab api capabilities for {0}, using the defaults instead till Sonarr restarts.", indexerSettings.Url); } return(capabilities); }
public NewznabRssParser(NewznabSettings settings) { PreferredEnclosureMimeTypes = UsenetEnclosureMimeTypes; UseEnclosureUrl = true; _settings = settings; }
public NewznabRssParser(NewznabSettings settings) { PreferredEnclosureMimeType = "application/x-nzb"; _settings = settings; }