Added searchEngine support in Newznab/Torznab caps
This commit is contained in:
parent
ab45910e56
commit
1cbcad6960
|
@ -97,5 +97,28 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests
|
|||
|
||||
ExceptionVerification.ExpectedErrors(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_use_default_searchengine_if_missing()
|
||||
{
|
||||
GivenCapsResponse(_caps);
|
||||
|
||||
var caps = Subject.GetCapabilities(_settings);
|
||||
|
||||
caps.TextSearchEngine.Should().Be("sphinx");
|
||||
caps.TvTextSearchEngine.Should().Be("sphinx");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_use_specified_searchengine()
|
||||
{
|
||||
GivenCapsResponse(_caps.Replace("<search ", "<search searchEngine=\"raw\" ")
|
||||
.Replace("<tv-search ", "<tv-search searchEngine=\"raw2\" "));
|
||||
|
||||
var caps = Subject.GetCapabilities(_settings);
|
||||
|
||||
caps.TextSearchEngine.Should().Be("raw");
|
||||
caps.TvTextSearchEngine.Should().Be("raw2");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@ namespace NzbDrone.Core.Indexers.Newznab
|
|||
public string[] SupportedSearchParameters { get; set; }
|
||||
public string[] SupportedTvSearchParameters { get; set; }
|
||||
public bool SupportsAggregateIdSearch { get; set; }
|
||||
public string TextSearchEngine { get; set; }
|
||||
public string TvTextSearchEngine { get; set; }
|
||||
public List<NewznabCategory> Categories { get; set; }
|
||||
|
||||
public NewznabCapabilities()
|
||||
|
@ -18,6 +20,8 @@ namespace NzbDrone.Core.Indexers.Newznab
|
|||
SupportedSearchParameters = new[] { "q" };
|
||||
SupportedTvSearchParameters = new[] { "q", "rid", "season", "ep" }; // This should remain 'rid' for older newznab installs.
|
||||
SupportsAggregateIdSearch = false;
|
||||
TextSearchEngine = "sphinx"; // This should remain 'sphinx' for odler newznab installs
|
||||
TvTextSearchEngine = "sphinx"; // This should remain 'sphinx' for odler newznab installs
|
||||
Categories = new List<NewznabCategory>();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -120,21 +120,29 @@ namespace NzbDrone.Core.Indexers.Newznab
|
|||
{
|
||||
capabilities.SupportedSearchParameters = null;
|
||||
}
|
||||
else if (xmlBasicSearch.Attribute("supportedParams") != null)
|
||||
else
|
||||
{
|
||||
if (xmlBasicSearch.Attribute("supportedParams") != null)
|
||||
{
|
||||
capabilities.SupportedSearchParameters = xmlBasicSearch.Attribute("supportedParams").Value.Split(',');
|
||||
}
|
||||
capabilities.TextSearchEngine = xmlBasicSearch.Attribute("searchEngine")?.Value ?? capabilities.TextSearchEngine;
|
||||
}
|
||||
|
||||
var xmlTvSearch = xmlSearching.Element("tv-search");
|
||||
if (xmlTvSearch == null || xmlTvSearch.Attribute("available").Value != "yes")
|
||||
{
|
||||
capabilities.SupportedTvSearchParameters = null;
|
||||
}
|
||||
else if (xmlTvSearch.Attribute("supportedParams") != null)
|
||||
else
|
||||
{
|
||||
if (xmlTvSearch.Attribute("supportedParams") != null)
|
||||
{
|
||||
capabilities.SupportedTvSearchParameters = xmlTvSearch.Attribute("supportedParams").Value.Split(',');
|
||||
capabilities.SupportsAggregateIdSearch = true;
|
||||
}
|
||||
capabilities.TvTextSearchEngine = xmlTvSearch.Attribute("searchEngine")?.Value ?? capabilities.TvTextSearchEngine;
|
||||
}
|
||||
}
|
||||
|
||||
var xmlCategories = xmlRoot.Element("categories");
|
||||
|
|
|
@ -121,6 +121,26 @@ namespace NzbDrone.Core.Indexers.Newznab
|
|||
}
|
||||
}
|
||||
|
||||
private string TextSearchEngine
|
||||
{
|
||||
get
|
||||
{
|
||||
var capabilities = _capabilitiesProvider.GetCapabilities(Settings);
|
||||
|
||||
return capabilities.TextSearchEngine;
|
||||
}
|
||||
}
|
||||
|
||||
private string TvTextSearchEngine
|
||||
{
|
||||
get
|
||||
{
|
||||
var capabilities = _capabilitiesProvider.GetCapabilities(Settings);
|
||||
|
||||
return capabilities.TvTextSearchEngine;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual IndexerPageableRequestChain GetRecentRequests()
|
||||
{
|
||||
var pageableRequests = new IndexerPageableRequestChain();
|
||||
|
@ -269,7 +289,8 @@ namespace NzbDrone.Core.Indexers.Newznab
|
|||
|
||||
if (SupportsSearch)
|
||||
{
|
||||
foreach (var queryTitle in searchCriteria.QueryTitles)
|
||||
var queryTitles = (TextSearchEngine == "raw" ? searchCriteria.SceneTitles : searchCriteria.QueryTitles);
|
||||
foreach (var queryTitle in queryTitles)
|
||||
{
|
||||
pageableRequests.Add(GetPagedRequests(MaxPages, Settings.AnimeCategories, "search",
|
||||
string.Format("&q={0}+{1:00}",
|
||||
|
@ -373,7 +394,8 @@ namespace NzbDrone.Core.Indexers.Newznab
|
|||
}
|
||||
else if (SupportsTvSearch)
|
||||
{
|
||||
foreach (var queryTitle in searchCriteria.QueryTitles)
|
||||
var queryTitles = TvTextSearchEngine == "raw" ? searchCriteria.SceneTitles : searchCriteria.QueryTitles;
|
||||
foreach (var queryTitle in queryTitles)
|
||||
{
|
||||
chain.Add(GetPagedRequests(MaxPages, Settings.Categories, "tvsearch",
|
||||
string.Format("&q={0}{1}",
|
||||
|
|
Loading…
Reference in New Issue