Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: show invalid releases in the interactive search #15243

Merged
merged 1 commit into from
Apr 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Jackett.Common/Indexers/AnimeBytes.cs
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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