mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
SubsPlease: Enable searching by resolution (#10861)
This commit is contained in:
@@ -69,9 +69,13 @@ namespace Jackett.Common.Indexers
|
|||||||
private async Task<IEnumerable<ReleaseInfo>> PerformSearch(TorznabQuery query)
|
private async Task<IEnumerable<ReleaseInfo>> PerformSearch(TorznabQuery query)
|
||||||
{
|
{
|
||||||
// If the search terms contain [SubsPlease] or SubsPlease, remove them from the query sent to the API
|
// If the search terms contain [SubsPlease] or SubsPlease, remove them from the query sent to the API
|
||||||
// It's ok if this results in an empty search term
|
|
||||||
string searchTerm = Regex.Replace(query.SearchTerm, "\\[?SubsPlease\\]?\\s*", string.Empty, RegexOptions.IgnoreCase).Trim();
|
string searchTerm = Regex.Replace(query.SearchTerm, "\\[?SubsPlease\\]?\\s*", string.Empty, RegexOptions.IgnoreCase).Trim();
|
||||||
|
|
||||||
|
// If the search terms contain a resolution, remove it from the query sent to the API
|
||||||
|
Match resMatch = Regex.Match(searchTerm, "\\d{3,4}[p|P]");
|
||||||
|
if (resMatch.Success)
|
||||||
|
searchTerm = searchTerm.Replace(resMatch.Value, string.Empty);
|
||||||
|
|
||||||
var queryParameters = new NameValueCollection
|
var queryParameters = new NameValueCollection
|
||||||
{
|
{
|
||||||
{ "f", "search" },
|
{ "f", "search" },
|
||||||
@@ -83,7 +87,13 @@ namespace Jackett.Common.Indexers
|
|||||||
throw new WebException($"SubsPlease search returned unexpected result. Expected 200 OK but got {response.Status}.", WebExceptionStatus.ProtocolError);
|
throw new WebException($"SubsPlease search returned unexpected result. Expected 200 OK but got {response.Status}.", WebExceptionStatus.ProtocolError);
|
||||||
|
|
||||||
var results = ParseApiResults(response.ContentString);
|
var results = ParseApiResults(response.ContentString);
|
||||||
return results.Where(release => query.MatchQueryStringAND(release.Title));
|
var filteredResults = results.Where(release => query.MatchQueryStringAND(release.Title));
|
||||||
|
|
||||||
|
// If we detected a resolution in the search terms earlier, filter by it
|
||||||
|
if (resMatch.Success)
|
||||||
|
filteredResults = filteredResults.Where(release => release.Title.IndexOf(resMatch.Value, StringComparison.OrdinalIgnoreCase) >= 0);
|
||||||
|
|
||||||
|
return filteredResults;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<IEnumerable<ReleaseInfo>> FetchNewReleases()
|
private async Task<IEnumerable<ReleaseInfo>> FetchNewReleases()
|
||||||
|
Reference in New Issue
Block a user