Skip to content

Commit

Permalink
cardigann: use MissingAttributeEqualsNoResults for `Search.Rows.Att…
Browse files Browse the repository at this point in the history
…ribute`

Fixes #14400
  • Loading branch information
mynameisbogdan committed May 29, 2023
1 parent e282ff7 commit 48ff682
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/Jackett.Common/Indexers/CardigannIndexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1457,18 +1457,24 @@ protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuer
if (SearchPath.Response != null && SearchPath.Response.Type.Equals("json"))
{
if (response.Status != HttpStatusCode.OK)
{
throw new Exception($"Error Parsing Json Response: Status={response.Status} Response={results}");
}

if (response.Status == HttpStatusCode.OK
&& SearchPath.Response != null
&& SearchPath.Response.NoResultsMessage != null
&& (SearchPath.Response.NoResultsMessage != string.Empty && results.Contains(SearchPath.Response.NoResultsMessage) || (SearchPath.Response.NoResultsMessage == string.Empty && results == string.Empty)))
{
continue;
}

var parsedJson = JToken.Parse(results);

if (parsedJson == null)
{
throw new Exception("Error Parsing Json Response");
}

if (Search.Rows.Count != null)
{
Expand All @@ -1492,7 +1498,9 @@ protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuer
if (rowsArray == null)
{
if (Search.Rows.MissingAttributeEqualsNoResults)
{
continue;
}

throw new Exception("Error Parsing Rows Selector. There are 0 rows.");
}
Expand All @@ -1504,7 +1512,18 @@ protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuer

foreach (var Row in rowsArray)
{
var selObj = Search.Rows.Attribute != null ? Row.SelectToken(Search.Rows.Attribute).Value<JToken>() : Row;
var selObj = Row;

if (Search.Rows.Attribute != null)
{
selObj = Row.SelectToken(Search.Rows.Attribute)?.Value<JToken>();

if (selObj == null && Search.Rows.MissingAttributeEqualsNoResults)
{
continue;
}
}

var mulRows = Search.Rows.Multiple ? selObj.Values<JObject>() : new List<JObject> { selObj.Value<JObject>() };

foreach (var mulRow in mulRows)
Expand Down

0 comments on commit 48ff682

Please sign in to comment.