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);
|
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[] SupportedSearchParameters { get; set; }
|
||||||
public string[] SupportedTvSearchParameters { get; set; }
|
public string[] SupportedTvSearchParameters { get; set; }
|
||||||
public bool SupportsAggregateIdSearch { get; set; }
|
public bool SupportsAggregateIdSearch { get; set; }
|
||||||
|
public string TextSearchEngine { get; set; }
|
||||||
|
public string TvTextSearchEngine { get; set; }
|
||||||
public List<NewznabCategory> Categories { get; set; }
|
public List<NewznabCategory> Categories { get; set; }
|
||||||
|
|
||||||
public NewznabCapabilities()
|
public NewznabCapabilities()
|
||||||
|
@ -18,6 +20,8 @@ namespace NzbDrone.Core.Indexers.Newznab
|
||||||
SupportedSearchParameters = new[] { "q" };
|
SupportedSearchParameters = new[] { "q" };
|
||||||
SupportedTvSearchParameters = new[] { "q", "rid", "season", "ep" }; // This should remain 'rid' for older newznab installs.
|
SupportedTvSearchParameters = new[] { "q", "rid", "season", "ep" }; // This should remain 'rid' for older newznab installs.
|
||||||
SupportsAggregateIdSearch = false;
|
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>();
|
Categories = new List<NewznabCategory>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,9 +120,13 @@ namespace NzbDrone.Core.Indexers.Newznab
|
||||||
{
|
{
|
||||||
capabilities.SupportedSearchParameters = null;
|
capabilities.SupportedSearchParameters = null;
|
||||||
}
|
}
|
||||||
else if (xmlBasicSearch.Attribute("supportedParams") != null)
|
else
|
||||||
{
|
{
|
||||||
capabilities.SupportedSearchParameters = xmlBasicSearch.Attribute("supportedParams").Value.Split(',');
|
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");
|
var xmlTvSearch = xmlSearching.Element("tv-search");
|
||||||
|
@ -130,10 +134,14 @@ namespace NzbDrone.Core.Indexers.Newznab
|
||||||
{
|
{
|
||||||
capabilities.SupportedTvSearchParameters = null;
|
capabilities.SupportedTvSearchParameters = null;
|
||||||
}
|
}
|
||||||
else if (xmlTvSearch.Attribute("supportedParams") != null)
|
else
|
||||||
{
|
{
|
||||||
capabilities.SupportedTvSearchParameters = xmlTvSearch.Attribute("supportedParams").Value.Split(',');
|
if (xmlTvSearch.Attribute("supportedParams") != null)
|
||||||
capabilities.SupportsAggregateIdSearch = true;
|
{
|
||||||
|
capabilities.SupportedTvSearchParameters = xmlTvSearch.Attribute("supportedParams").Value.Split(',');
|
||||||
|
capabilities.SupportsAggregateIdSearch = true;
|
||||||
|
}
|
||||||
|
capabilities.TvTextSearchEngine = xmlTvSearch.Attribute("searchEngine")?.Value ?? capabilities.TvTextSearchEngine;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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()
|
public virtual IndexerPageableRequestChain GetRecentRequests()
|
||||||
{
|
{
|
||||||
var pageableRequests = new IndexerPageableRequestChain();
|
var pageableRequests = new IndexerPageableRequestChain();
|
||||||
|
@ -269,7 +289,8 @@ namespace NzbDrone.Core.Indexers.Newznab
|
||||||
|
|
||||||
if (SupportsSearch)
|
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",
|
pageableRequests.Add(GetPagedRequests(MaxPages, Settings.AnimeCategories, "search",
|
||||||
string.Format("&q={0}+{1:00}",
|
string.Format("&q={0}+{1:00}",
|
||||||
|
@ -373,7 +394,8 @@ namespace NzbDrone.Core.Indexers.Newznab
|
||||||
}
|
}
|
||||||
else if (SupportsTvSearch)
|
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",
|
chain.Add(GetPagedRequests(MaxPages, Settings.Categories, "tvsearch",
|
||||||
string.Format("&q={0}{1}",
|
string.Format("&q={0}{1}",
|
||||||
|
|
Loading…
Reference in New Issue