mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-16 11:37:58 +02:00
Fixed: Indexer testing
Omg now has a preprocessor to catch authentication issues Indexer testing works again, instead of always being successful
This commit is contained in:
parent
33ca71a745
commit
a8ca258ca4
@ -2,7 +2,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Text;
|
|
||||||
using FluentValidation.Results;
|
using FluentValidation.Results;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Common;
|
using NzbDrone.Common;
|
||||||
@ -186,9 +185,8 @@ protected virtual Boolean IsFullPage(IList<ReleaseInfo> page)
|
|||||||
|
|
||||||
protected virtual IList<ReleaseInfo> FetchPage(IndexerRequest request, IParseIndexerResponse parser)
|
protected virtual IList<ReleaseInfo> FetchPage(IndexerRequest request, IParseIndexerResponse parser)
|
||||||
{
|
{
|
||||||
var url = request.Url;
|
|
||||||
|
|
||||||
_logger.Debug("Downloading Feed " + request.Url);
|
_logger.Debug("Downloading Feed " + request.Url);
|
||||||
|
|
||||||
var response = new IndexerResponse(request, _httpClient.Execute(request.HttpRequest));
|
var response = new IndexerResponse(request, _httpClient.Execute(request.HttpRequest));
|
||||||
|
|
||||||
return parser.ParseResponse(response).ToList();
|
return parser.ParseResponse(response).ToList();
|
||||||
@ -201,12 +199,16 @@ protected override void Test(List<ValidationFailure> failures)
|
|||||||
|
|
||||||
protected virtual ValidationFailure TestConnection()
|
protected virtual ValidationFailure TestConnection()
|
||||||
{
|
{
|
||||||
// TODO: This doesn't even work coz those exceptions get catched.
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var releases = FetchRecent();
|
var parser = GetParser();
|
||||||
|
var generator = GetRequestGenerator();
|
||||||
|
var releases = FetchPage(generator.GetRecentRequests().First().First(), parser);
|
||||||
|
|
||||||
if (releases.Any()) return null;
|
if (releases.Empty())
|
||||||
|
{
|
||||||
|
return new ValidationFailure("Url", "No results were returned from your indexer, please check your settings.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (ApiKeyException)
|
catch (ApiKeyException)
|
||||||
{
|
{
|
||||||
|
@ -45,7 +45,6 @@ protected override ReleaseInfo ProcessItem(XElement item, ReleaseInfo releaseInf
|
|||||||
return releaseInfo;
|
return releaseInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected override String GetInfoUrl(XElement item)
|
protected override String GetInfoUrl(XElement item)
|
||||||
{
|
{
|
||||||
return item.TryGetValue("comments").TrimEnd("#comments");
|
return item.TryGetValue("comments").TrimEnd("#comments");
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
using NzbDrone.Core.Indexers.Exceptions;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Indexers.Omgwtfnzbs
|
namespace NzbDrone.Core.Indexers.Omgwtfnzbs
|
||||||
{
|
{
|
||||||
@ -12,6 +14,16 @@ public OmgwtfnzbsRssParser()
|
|||||||
UseEnclosureLength = true;
|
UseEnclosureLength = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override bool PreProcess(IndexerResponse indexerResponse)
|
||||||
|
{
|
||||||
|
var xdoc = XDocument.Parse(indexerResponse.Content);
|
||||||
|
var notice = xdoc.Descendants("notice").FirstOrDefault();
|
||||||
|
|
||||||
|
if (notice == null) return true;
|
||||||
|
|
||||||
|
throw new ApiKeyException(notice.Value);
|
||||||
|
}
|
||||||
|
|
||||||
protected override string GetInfoUrl(XElement item)
|
protected override string GetInfoUrl(XElement item)
|
||||||
{
|
{
|
||||||
//Todo: Me thinks I need to parse details to get this...
|
//Todo: Me thinks I need to parse details to get this...
|
||||||
|
Loading…
Reference in New Issue
Block a user