mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-11 20:12:41 +02:00
Added searchEngine support in Newznab/Torznab caps
Fixes #5849 Co-Authored-By: Taloth <Taloth@users.noreply.github.com>
This commit is contained in:
parent
143067621c
commit
eb76dd5248
@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using Moq;
|
using Moq;
|
||||||
@ -95,5 +95,28 @@ public void should_not_throw_on_xml_data_unexpected()
|
|||||||
|
|
||||||
result.Should().NotBeNull();
|
result.Should().NotBeNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_use_default_searchengine_if_missing()
|
||||||
|
{
|
||||||
|
GivenCapsResponse(_caps);
|
||||||
|
|
||||||
|
var caps = Subject.GetCapabilities(_settings);
|
||||||
|
|
||||||
|
caps.TextSearchEngine.Should().Be("sphinx");
|
||||||
|
caps.MovieTextSearchEngine.Should().Be("sphinx");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_use_specified_searchengine()
|
||||||
|
{
|
||||||
|
GivenCapsResponse(_caps.Replace("<search ", "<search searchEngine=\"raw\" ")
|
||||||
|
.Replace("<movie-search ", "<movie-search searchEngine=\"raw2\" "));
|
||||||
|
|
||||||
|
var caps = Subject.GetCapabilities(_settings);
|
||||||
|
|
||||||
|
caps.TextSearchEngine.Should().Be("raw");
|
||||||
|
caps.MovieTextSearchEngine.Should().Be("raw2");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,8 @@ public class NewznabCapabilities
|
|||||||
public string[] SupportedSearchParameters { get; set; }
|
public string[] SupportedSearchParameters { get; set; }
|
||||||
public string[] SupportedMovieSearchParameters { get; set; }
|
public string[] SupportedMovieSearchParameters { get; set; }
|
||||||
public bool SupportsAggregateIdSearch { get; set; }
|
public bool SupportsAggregateIdSearch { get; set; }
|
||||||
|
public string TextSearchEngine { get; set; }
|
||||||
|
public string MovieTextSearchEngine { get; set; }
|
||||||
public List<NewznabCategory> Categories { get; set; }
|
public List<NewznabCategory> Categories { get; set; }
|
||||||
|
|
||||||
public NewznabCapabilities()
|
public NewznabCapabilities()
|
||||||
@ -18,6 +20,8 @@ public NewznabCapabilities()
|
|||||||
SupportedSearchParameters = new[] { "q" };
|
SupportedSearchParameters = new[] { "q" };
|
||||||
SupportedMovieSearchParameters = new[] { "q", "imdbid", "imdbtitle", "imdbyear" };
|
SupportedMovieSearchParameters = new[] { "q", "imdbid", "imdbtitle", "imdbyear" };
|
||||||
SupportsAggregateIdSearch = false;
|
SupportsAggregateIdSearch = false;
|
||||||
|
TextSearchEngine = "sphinx"; // This should remain 'sphinx' for older newznab installs
|
||||||
|
MovieTextSearchEngine = "sphinx"; // This should remain 'sphinx' for older newznab installs
|
||||||
Categories = new List<NewznabCategory>();
|
Categories = new List<NewznabCategory>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,9 +118,14 @@ private NewznabCapabilities ParseCapabilities(HttpResponse response)
|
|||||||
{
|
{
|
||||||
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 xmlMovieSearch = xmlSearching.Element("movie-search");
|
var xmlMovieSearch = xmlSearching.Element("movie-search");
|
||||||
@ -128,10 +133,15 @@ private NewznabCapabilities ParseCapabilities(HttpResponse response)
|
|||||||
{
|
{
|
||||||
capabilities.SupportedMovieSearchParameters = null;
|
capabilities.SupportedMovieSearchParameters = null;
|
||||||
}
|
}
|
||||||
else if (xmlMovieSearch.Attribute("supportedParams") != null)
|
else
|
||||||
{
|
{
|
||||||
capabilities.SupportedMovieSearchParameters = xmlMovieSearch.Attribute("supportedParams").Value.Split(',');
|
if (xmlMovieSearch.Attribute("supportedParams") != null)
|
||||||
capabilities.SupportsAggregateIdSearch = true;
|
{
|
||||||
|
capabilities.SupportedMovieSearchParameters = xmlMovieSearch.Attribute("supportedParams").Value.Split(',');
|
||||||
|
capabilities.SupportsAggregateIdSearch = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
capabilities.MovieTextSearchEngine = xmlMovieSearch.Attribute("searchEngine")?.Value ?? capabilities.MovieTextSearchEngine;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,6 +65,26 @@ private bool SupportsAggregatedIdSearch
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string TextSearchEngine
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var capabilities = _capabilitiesProvider.GetCapabilities(Settings);
|
||||||
|
|
||||||
|
return capabilities.TextSearchEngine;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string MovieTextSearchEngine
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var capabilities = _capabilitiesProvider.GetCapabilities(Settings);
|
||||||
|
|
||||||
|
return capabilities.MovieTextSearchEngine;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public virtual IndexerPageableRequestChain GetRecentRequests()
|
public virtual IndexerPageableRequestChain GetRecentRequests()
|
||||||
{
|
{
|
||||||
var pageableRequests = new IndexerPageableRequestChain();
|
var pageableRequests = new IndexerPageableRequestChain();
|
||||||
@ -135,7 +155,8 @@ private void AddMovieIdPageableRequests(IndexerPageableRequestChain chain, int m
|
|||||||
if (SupportsSearch)
|
if (SupportsSearch)
|
||||||
{
|
{
|
||||||
chain.AddTier();
|
chain.AddTier();
|
||||||
foreach (var queryTitle in searchCriteria.QueryTitles)
|
var queryTitles = TextSearchEngine == "raw" ? searchCriteria.SceneTitles : searchCriteria.QueryTitles;
|
||||||
|
foreach (var queryTitle in queryTitles)
|
||||||
{
|
{
|
||||||
var searchQuery = queryTitle;
|
var searchQuery = queryTitle;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user