YTS: handle YTS bug where count>0 but no movies. Resolves #12598

This commit is contained in:
Garfield69 2022-02-27 08:23:37 +13:00
parent bc7af6249c
commit 4095bd030d
3 changed files with 16 additions and 4 deletions

View File

@ -66,6 +66,8 @@ search:
selector: data.movies
attribute: torrents
multiple: true
# bug at YTS can return movie_count > 0 and no movie torrents #12598
missingAttributeEquals0Results: true
count:
selector: data.movie_count

View File

@ -1407,6 +1407,8 @@ namespace Jackett.Common.Indexers
}
var rowsArray = JsonParseRowsSelector(parsedJson, Search.Rows.Selector);
if (rowsArray == null && Search.Rows.MissingAttributeEquals0Results)
continue;
if (rowsArray == null)
throw new Exception("Error Parsing Rows Selector. There are 0 rows.");
@ -2100,10 +2102,17 @@ namespace Jackett.Common.Indexers
private JArray JsonParseRowsSelector(JToken parsedJson, string rowSelector)
{
var selector = rowSelector.Split(':')[0];
var rowsObj = parsedJson.SelectToken(selector).Value<JArray>();
return new JArray(rowsObj.Where(t =>
JsonParseFieldSelector(t.Value<JObject>(), rowSelector.Remove(0, selector.Length)) != null
));
try
{
var rowsObj = parsedJson.SelectToken(selector).Value<JArray>();
return new JArray(rowsObj.Where(t =>
JsonParseFieldSelector(t.Value<JObject>(), rowSelector.Remove(0, selector.Length)) != null
));
}
catch
{
return null;
}
}
private string JsonParseFieldSelector(JToken parsedJson, string rowSelector)

View File

@ -152,6 +152,7 @@ namespace Jackett.Common.Models
public selectorBlock Dateheaders { get; set; }
public selectorBlock Count { get; set; }
public bool Multiple { get; set; } = false;
public bool MissingAttributeEquals0Results { get; set; } = false;
}
public class searchPathBlock : requestBlock