Skip to content

Commit

Permalink
core: show invalid releases in the interactive search (#15243)
Browse files Browse the repository at this point in the history
  • Loading branch information
mynameisbogdan committed Apr 13, 2024
1 parent 3878873 commit f94d272
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/Jackett.Common/Indexers/AnimeBytes.cs
Expand Up @@ -470,6 +470,10 @@ private async Task<IEnumerable<ReleaseInfo>> GetResults(TorznabQuery query, stri
{
// Ignore these categories as they'll cause hell with the matcher
// TV Special, DVD Special, BD Special
if (groupName == "TV Special" || groupName == "DVD Special" || groupName == "BD Special")
{
continue;
}

if (groupName == "TV Series" || groupName == "OVA" || groupName == "ONA")
{
Expand Down
10 changes: 8 additions & 2 deletions src/Jackett.Common/Indexers/BaseIndexer.cs
Expand Up @@ -165,7 +165,7 @@ protected async Task ConfigureIfOK(string cookies, bool isLoggedin, Func<Task> o

protected virtual IEnumerable<ReleaseInfo> FilterResults(TorznabQuery query, IEnumerable<ReleaseInfo> results)
{
var filteredResults = results.Where(IsValidRelease).ToList();
var filteredResults = results.Where(r => IsValidRelease(r, query.InteractiveSearch)).ToList();

// filter results with wrong categories
if (query.Categories.Length > 0)
Expand Down Expand Up @@ -237,7 +237,7 @@ protected virtual IEnumerable<ReleaseInfo> FixResults(TorznabQuery query, IEnume
return fixedResults;
}

protected virtual bool IsValidRelease(ReleaseInfo release)
protected virtual bool IsValidRelease(ReleaseInfo release, bool interactiveSearch)
{
if (release.Title.IsNullOrWhiteSpace())
{
Expand All @@ -246,6 +246,12 @@ protected virtual bool IsValidRelease(ReleaseInfo release)
return false;
}

if (interactiveSearch)
{
// Show releases with issues in the interactive search
return true;
}

if (release.Size == null)
{
logger.Warn("[{0}] Invalid Release: '{1}'. No size provided.", Id, release.Details);
Expand Down
4 changes: 3 additions & 1 deletion src/Jackett.Common/Models/TorznabQuery.cs
Expand Up @@ -13,6 +13,7 @@ public class TorznabQuery
private static readonly Regex _StandardizeDashesRegex = new Regex(@"\p{Pd}+", RegexOptions.Compiled);
private static readonly Regex _StandardizeSingleQuotesRegex = new Regex(@"[\u0060\u00B4\u2018\u2019]", RegexOptions.Compiled);

public bool InteractiveSearch { get; set; }
public string QueryType { get; set; }
public int[] Categories { get; set; }
public int Extended { get; set; }
Expand Down Expand Up @@ -167,6 +168,7 @@ public TorznabQuery Clone()
{
var ret = new TorznabQuery
{
InteractiveSearch = InteractiveSearch,
QueryType = QueryType,
Extended = Extended,
ApiKey = ApiKey,
Expand Down Expand Up @@ -212,7 +214,7 @@ public TorznabQuery Clone()

// Some trackers don't support AND logic for search terms resulting in unwanted results.
// Using this method we can AND filter it within jackett.
// With limit we can limit the amount of characters which should be compared (use it if a tracker doesn't return the full title).
// With "limit" we can limit the amount of characters which should be compared (use it if a tracker doesn't return the full title).
public bool MatchQueryStringAND(string title, int? limit = null, string queryStringOverride = null)
{
var commonWords = new[] { "and", "the", "an" };
Expand Down
7 changes: 5 additions & 2 deletions src/Jackett.Server/Controllers/ResultsController.cs
Expand Up @@ -236,17 +236,20 @@ public async Task<IActionResult> Results([FromQuery] ApiSearch requestt)

var manualResult = new ManualSearchResult();

var trackers = CurrentIndexer is BaseMetaIndexer
? (CurrentIndexer as BaseMetaIndexer).ValidIndexers
var trackers = CurrentIndexer is BaseMetaIndexer metaIndexer
? metaIndexer.ValidIndexers
: (new[] { CurrentIndexer });

// Filter current trackers list on Tracker query parameter if available
if (request.Tracker != null)
trackers = trackers.Where(t => request.Tracker.Contains(t.Id));
trackers = trackers.Where(t => t.CanHandleQuery(CurrentQuery));

CurrentQuery.InteractiveSearch = true;

var isMetaIndexer = request.Tracker == null || request.Tracker.Length > 1;
var tasks = trackers.ToList().Select(t => t.ResultsForQuery(CurrentQuery, isMetaIndexer)).ToList();

try
{
var aggregateTask = Task.WhenAll(tasks);
Expand Down

0 comments on commit f94d272

Please sign in to comment.