Fixed: (HDBits) Treat 403 as Query Limit

pull/931/head
bakerboy448 3 years ago
parent c4468b9cbb
commit 1959efbd09

@ -23,29 +23,29 @@ namespace NzbDrone.Core.Indexers.HDBits
public IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse) public IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
{ {
var torrentInfos = new List<ReleaseInfo>(); var torrentInfos = new List<ReleaseInfo>();
var indexerHttpResponse = indexerResponse.HttpResponse;
if (indexerResponse.HttpResponse.StatusCode != HttpStatusCode.OK) if (indexerHttpResponse.StatusCode == HttpStatusCode.Forbidden)
{ {
throw new IndexerException(indexerResponse, throw new RequestLimitReachedException(indexerResponse, "HDBits Query Limit Reached. Please try again later.");
"Unexpected response status {0} code from API request", }
indexerResponse.HttpResponse.StatusCode);
if (indexerHttpResponse.StatusCode != HttpStatusCode.OK)
{
throw new IndexerException(indexerResponse, "Unexpected response status {0} code from API request", indexerHttpResponse.StatusCode);
} }
var jsonResponse = JsonConvert.DeserializeObject<HDBitsResponse>(indexerResponse.Content); var jsonResponse = JsonConvert.DeserializeObject<HDBitsResponse>(indexerResponse.Content);
if (jsonResponse.Status != StatusCode.Success) if (jsonResponse.Status != StatusCode.Success)
{ {
throw new IndexerException(indexerResponse, throw new IndexerException(indexerResponse, "HDBits API request returned status code {0}: {1}", jsonResponse.Status, jsonResponse.Message ?? string.Empty);
"HDBits API request returned status code {0}: {1}",
jsonResponse.Status,
jsonResponse.Message ?? string.Empty);
} }
var responseData = jsonResponse.Data as JArray; var responseData = jsonResponse.Data as JArray;
if (responseData == null) if (responseData == null)
{ {
throw new IndexerException(indexerResponse, throw new IndexerException(indexerResponse, "Indexer API call response missing result data");
"Indexer API call response missing result data");
} }
var queryResults = responseData.ToObject<TorrentQueryResponse[]>(); var queryResults = responseData.ToObject<TorrentQueryResponse[]>();

Loading…
Cancel
Save