Fixed: (Rarbg) Simplify retry fetching for expired tokens

pull/1618/head
Bogdan 2 years ago
parent 17be8bb68a
commit 28d09cd384

@ -58,7 +58,7 @@ namespace NzbDrone.Core.Indexers.Definitions.Rarbg
case (int)HttpStatusCode.OK:
break;
default:
throw new IndexerException(response, "Indexer API call returned an unexpected StatusCode [{0}]", responseCode);
throw new IndexerException(response, "Indexer API call returned an unexpected status code [{0}]", responseCode);
}
}
@ -112,9 +112,9 @@ namespace NzbDrone.Core.Indexers.Definitions.Rarbg
return caps;
}
protected override async Task<IndexerQueryResult> FetchPage(IndexerRequest request, IParseIndexerResponse parser)
protected override async Task<IndexerResponse> FetchIndexerResponse(IndexerRequest request)
{
var response = await FetchIndexerResponse(request);
var response = await base.FetchIndexerResponse(request);
CheckResponseByStatusCode(response);
@ -133,36 +133,19 @@ namespace NzbDrone.Core.Indexers.Definitions.Rarbg
qs.Set("token", newToken);
request.HttpRequest.Url = request.Url.SetQuery(qs.GetQueryString());
response = await FetchIndexerResponse(request);
return await FetchIndexerResponse(request);
}
else if (jsonResponse.Resource.error_code is 5)
if (jsonResponse.Resource.error_code is 5)
{
_logger.Debug("Rarbg temp rate limit hit, retrying request");
response = await FetchIndexerResponse(request);
}
}
try
{
var releases = parser.ParseResponse(response).ToList();
if (releases.Count == 0)
{
_logger.Trace(response.Content);
return await FetchIndexerResponse(request);
}
return new IndexerQueryResult
{
Releases = releases,
Response = response.HttpResponse
};
}
catch (Exception ex)
{
ex.WithData(response.HttpResponse, 128 * 1024);
_logger.Trace("Unexpected Response content ({0} bytes): {1}", response.HttpResponse.ResponseData.Length, response.HttpResponse.Content);
throw;
}
return response;
}
public override object RequestAction(string action, IDictionary<string, string> query)

@ -46,11 +46,11 @@ namespace NzbDrone.Core.Indexers.Definitions.Rarbg
{
requestBuilder.AddQueryParam("search_imdb", imdbId);
}
else if (tmdbId.HasValue && tmdbId > 0)
else if (tmdbId is > 0)
{
requestBuilder.AddQueryParam("search_themoviedb", tmdbId);
}
else if (tvdbId.HasValue && tvdbId > 0)
else if (tvdbId is > 0)
{
requestBuilder.AddQueryParam("search_tvdb", tvdbId);
}

@ -47,7 +47,7 @@ namespace NzbDrone.Core.Indexers.Definitions.Rarbg
return response.Resource["token"].ToString();
},
TimeSpan.FromMinutes(14.0));
TimeSpan.FromMinutes(14));
}
}
}

Loading…
Cancel
Save