rarbg: add non json response detection. resolves #13350

This commit is contained in:
Garfield69 2022-07-11 07:33:32 +12:00
parent 84f3811ce7
commit 86d7a55329
1 changed files with 6 additions and 0 deletions

View File

@ -141,6 +141,12 @@ namespace Jackett.Common.Indexers
await RenewalTokenAsync(); await RenewalTokenAsync();
var response = await RequestWithCookiesAndRetryAsync(BuildSearchUrl(query)); var response = await RequestWithCookiesAndRetryAsync(BuildSearchUrl(query));
if (response != null && response.ContentString.StartsWith("<"))
{
// the response was not JSON, likely a HTML page for a server outage
logger.Warn(response.ContentString);
throw new Exception("The response was not JSON");
}
var jsonContent = JObject.Parse(response.ContentString); var jsonContent = JObject.Parse(response.ContentString);
var errorCode = jsonContent.Value<int>("error_code"); var errorCode = jsonContent.Value<int>("error_code");
switch (errorCode) switch (errorCode)