gazellegames-api: fix parsing error when no results are returned

Fixes #15513
This commit is contained in:
Bogdan 2024-07-28 01:36:12 +03:00
parent b3e7072f0f
commit 52d970f312
1 changed files with 8 additions and 2 deletions

View File

@ -258,7 +258,8 @@ namespace Jackett.Common.Indexers.Definitions
await ApplyConfiguration(null); await ApplyConfiguration(null);
response = await RequestWithCookiesAndRetryAsync(searchUrl); response = await RequestWithCookiesAndRetryAsync(searchUrl);
} }
else if (response.ContentString != null && response.ContentString.Contains("failure") && useApiKey)
if (response.ContentString != null && response.ContentString.Contains("failure") && useApiKey)
{ {
// reason for failure should be explained. // reason for failure should be explained.
var jsonError = JObject.Parse(response.ContentString); var jsonError = JObject.Parse(response.ContentString);
@ -270,7 +271,12 @@ namespace Jackett.Common.Indexers.Definitions
{ {
var json = JObject.Parse(response.ContentString); var json = JObject.Parse(response.ContentString);
foreach (var gObj in JObject.FromObject(json["response"])) if (json.Value<object>("response") is not JObject results)
{
return releases;
}
foreach (var gObj in results)
{ {
var groupId = int.Parse(gObj.Key); var groupId = int.Parse(gObj.Key);
var group = gObj.Value as JObject; var group = gObj.Value as JObject;