|
|
|
@ -82,83 +82,85 @@ namespace NzbDrone.Core.Indexers.Definitions
|
|
|
|
|
_settings = settings;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private IEnumerable<IndexerRequest> GetSearchRequests(string term)
|
|
|
|
|
public IndexerPageableRequestChain GetSearchRequests(MovieSearchCriteria searchCriteria)
|
|
|
|
|
{
|
|
|
|
|
var searchUrl = $"{_settings.BaseUrl.TrimEnd('/')}/api/?";
|
|
|
|
|
|
|
|
|
|
var searchTerm = Regex.Replace(term, "\\[?SubsPlease\\]?\\s*", string.Empty, RegexOptions.IgnoreCase).Trim();
|
|
|
|
|
|
|
|
|
|
// If the search terms contain a resolution, remove it from the query sent to the API
|
|
|
|
|
var resMatch = Regex.Match(searchTerm, "\\d{3,4}[p|P]");
|
|
|
|
|
if (resMatch.Success)
|
|
|
|
|
{
|
|
|
|
|
searchTerm = searchTerm.Replace(resMatch.Value, string.Empty);
|
|
|
|
|
}
|
|
|
|
|
var pageableRequests = new IndexerPageableRequestChain();
|
|
|
|
|
|
|
|
|
|
var queryParameters = new NameValueCollection
|
|
|
|
|
{
|
|
|
|
|
{ "f", "search" },
|
|
|
|
|
{ "tz", "UTC" },
|
|
|
|
|
{ "s", searchTerm }
|
|
|
|
|
};
|
|
|
|
|
pageableRequests.Add(GetSearchRequests(searchCriteria.SanitizedSearchTerm, searchCriteria));
|
|
|
|
|
|
|
|
|
|
var request = new IndexerRequest(searchUrl + queryParameters.GetQueryString(), HttpAccept.Json);
|
|
|
|
|
return pageableRequests;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
yield return request;
|
|
|
|
|
public IndexerPageableRequestChain GetSearchRequests(MusicSearchCriteria searchCriteria)
|
|
|
|
|
{
|
|
|
|
|
return new IndexerPageableRequestChain();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private IEnumerable<IndexerRequest> GetRssRequest()
|
|
|
|
|
public IndexerPageableRequestChain GetSearchRequests(TvSearchCriteria searchCriteria)
|
|
|
|
|
{
|
|
|
|
|
var searchUrl = $"{_settings.BaseUrl.TrimEnd('/')}/api/?";
|
|
|
|
|
var pageableRequests = new IndexerPageableRequestChain();
|
|
|
|
|
|
|
|
|
|
var queryParameters = new NameValueCollection
|
|
|
|
|
var searchTerm = searchCriteria.SanitizedSearchTerm.Trim();
|
|
|
|
|
|
|
|
|
|
// Only include season > 1 in searchTerm, format as S2 rather than S02
|
|
|
|
|
if (searchCriteria.Season is > 1)
|
|
|
|
|
{
|
|
|
|
|
{ "f", "latest" },
|
|
|
|
|
{ "tz", "UTC" }
|
|
|
|
|
};
|
|
|
|
|
searchTerm += $" S{searchCriteria.Season}";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var request = new IndexerRequest(searchUrl + queryParameters.GetQueryString(), HttpAccept.Json);
|
|
|
|
|
if (int.TryParse(searchCriteria.Episode, out var episode) && episode > 0)
|
|
|
|
|
{
|
|
|
|
|
searchTerm += $" {episode:00}";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
yield return request;
|
|
|
|
|
}
|
|
|
|
|
pageableRequests.Add(GetSearchRequests(searchTerm, searchCriteria));
|
|
|
|
|
|
|
|
|
|
public IndexerPageableRequestChain GetSearchRequests(MovieSearchCriteria searchCriteria)
|
|
|
|
|
{
|
|
|
|
|
return new IndexerPageableRequestChain();
|
|
|
|
|
return pageableRequests;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IndexerPageableRequestChain GetSearchRequests(MusicSearchCriteria searchCriteria)
|
|
|
|
|
public IndexerPageableRequestChain GetSearchRequests(BookSearchCriteria searchCriteria)
|
|
|
|
|
{
|
|
|
|
|
return new IndexerPageableRequestChain();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IndexerPageableRequestChain GetSearchRequests(TvSearchCriteria searchCriteria)
|
|
|
|
|
public IndexerPageableRequestChain GetSearchRequests(BasicSearchCriteria searchCriteria)
|
|
|
|
|
{
|
|
|
|
|
var pageableRequests = new IndexerPageableRequestChain();
|
|
|
|
|
|
|
|
|
|
pageableRequests.Add(searchCriteria.IsRssSearch
|
|
|
|
|
? GetRssRequest()
|
|
|
|
|
: GetSearchRequests(searchCriteria.SanitizedTvSearchString));
|
|
|
|
|
pageableRequests.Add(GetSearchRequests(searchCriteria.SanitizedSearchTerm, searchCriteria));
|
|
|
|
|
|
|
|
|
|
return pageableRequests;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IndexerPageableRequestChain GetSearchRequests(BookSearchCriteria searchCriteria)
|
|
|
|
|
private IEnumerable<IndexerRequest> GetSearchRequests(string term, SearchCriteriaBase searchCriteria)
|
|
|
|
|
{
|
|
|
|
|
var pageableRequests = new IndexerPageableRequestChain();
|
|
|
|
|
var searchTerm = Regex.Replace(term, "\\[?SubsPlease\\]?\\s*", string.Empty, RegexOptions.IgnoreCase).Trim();
|
|
|
|
|
|
|
|
|
|
return pageableRequests;
|
|
|
|
|
}
|
|
|
|
|
// If the search terms contain a resolution, remove it from the query sent to the API
|
|
|
|
|
var resMatch = Regex.Match(searchTerm, "\\d{3,4}[p|P]");
|
|
|
|
|
if (resMatch.Success)
|
|
|
|
|
{
|
|
|
|
|
searchTerm = searchTerm.Replace(resMatch.Value, string.Empty).Trim();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IndexerPageableRequestChain GetSearchRequests(BasicSearchCriteria searchCriteria)
|
|
|
|
|
{
|
|
|
|
|
var pageableRequests = new IndexerPageableRequestChain();
|
|
|
|
|
var queryParameters = new NameValueCollection
|
|
|
|
|
{
|
|
|
|
|
{ "tz", "UTC" }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
pageableRequests.Add(searchCriteria.IsRssSearch
|
|
|
|
|
? GetRssRequest()
|
|
|
|
|
: GetSearchRequests(searchCriteria.SanitizedSearchTerm));
|
|
|
|
|
if (searchCriteria.IsRssSearch)
|
|
|
|
|
{
|
|
|
|
|
queryParameters.Set("f", "latest");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
queryParameters.Set("f", "search");
|
|
|
|
|
queryParameters.Set("s", searchTerm);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return pageableRequests;
|
|
|
|
|
var searchUrl = $"{_settings.BaseUrl.TrimEnd('/')}/api/?{queryParameters.GetQueryString()}";
|
|
|
|
|
|
|
|
|
|
yield return new IndexerRequest(searchUrl, HttpAccept.Json);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Func<IDictionary<string, string>> GetCookies { get; set; }
|
|
|
|
|