mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
assorted: fix response status checks
This commit is contained in:
@@ -184,19 +184,32 @@ namespace Jackett.Common.Indexers.Abstract
|
||||
var episodeSearchUrl = SearchUrl + "?" + qc.GetQueryString();
|
||||
|
||||
var response = await RequestWithCookiesAndRetryAsync(episodeSearchUrl, headers: GetSearchHeaders());
|
||||
|
||||
if (response.Status == HttpStatusCode.Unauthorized || response.Status == HttpStatusCode.PreconditionFailed)
|
||||
{
|
||||
await RenewalTokenAsync();
|
||||
response = await RequestWithCookiesAndRetryAsync(episodeSearchUrl, headers: GetSearchHeaders());
|
||||
}
|
||||
else if (response.Status == HttpStatusCode.NotFound)
|
||||
|
||||
if (response.Status == HttpStatusCode.NotFound)
|
||||
{
|
||||
return releases; // search without results, eg CinemaZ: tt0075998
|
||||
else if (response.Status != HttpStatusCode.OK)
|
||||
throw new Exception($"Unknown error: {response.ContentString}");
|
||||
}
|
||||
|
||||
if ((int)response.Status >= 400)
|
||||
{
|
||||
throw new Exception($"Invalid status code {(int)response.Status} ({response.Status}) received from indexer");
|
||||
}
|
||||
|
||||
if (response.Status != HttpStatusCode.OK)
|
||||
{
|
||||
throw new Exception($"Unknown status code: {(int)response.Status} ({response.Status})");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var jsonContent = JToken.Parse(response.ContentString);
|
||||
|
||||
foreach (var row in jsonContent.Value<JArray>("data"))
|
||||
{
|
||||
var details = new Uri(row.Value<string>("url"));
|
||||
@@ -265,6 +278,7 @@ namespace Jackett.Common.Indexers.Abstract
|
||||
{
|
||||
OnParseError(response.ContentString, ex);
|
||||
}
|
||||
|
||||
return releases;
|
||||
}
|
||||
|
||||
|
@@ -214,16 +214,18 @@ namespace Jackett.Common.Indexers.Abstract
|
||||
await ApplyConfiguration(null);
|
||||
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.
|
||||
var jsonError = JObject.Parse(response.ContentString);
|
||||
var errorReason = (string)jsonError["error"];
|
||||
throw new Exception(errorReason);
|
||||
}
|
||||
else if ((int)response.Status >= 400)
|
||||
|
||||
if ((int)response.Status >= 400)
|
||||
{
|
||||
throw new Exception($"Invalid status code {response.Status} received from indexer");
|
||||
throw new Exception($"Invalid status code {(int)response.Status} ({response.Status}) received from indexer");
|
||||
}
|
||||
|
||||
try
|
||||
|
Reference in New Issue
Block a user