Skip to content

Commit

Permalink
ГОСТ 5812-82
Browse files Browse the repository at this point in the history
  • Loading branch information
OnlyFart committed Dec 7, 2024
1 parent 9c04077 commit 15eb34d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Core/Configs/BookGetterConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage
responseMessage = await base.SendAsync(request, cancellationToken);
}

if (responseMessage.StatusCode == HttpStatusCode.TooManyRequests) {
responseMessage.StatusCode = HttpStatusCode.Forbidden;
}

return responseMessage;
} catch (TaskCanceledException ex) when (ex.InnerException is TimeoutException) {
_logger.LogInformation("Сервер не успевает ответить. Попробуйте увеличить Timeout с помощью параметра -t");
Expand Down
2 changes: 1 addition & 1 deletion Core/Logic/Getters/BookstabGetter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private async Task<IEnumerable<Chapter>> FillChapters(BookstabApiResponse respon
private async Task<HtmlDocument> GetChapter(int chapterId, string bookId) {
while (true) {
using var response = await Config.Client.GetAsync(_apiUrl.MakeRelativeUri($"/api/reader-get/{bookId}/{chapterId}"));
if (response.StatusCode == HttpStatusCode.TooManyRequests) {
if (response.StatusCode == HttpStatusCode.Forbidden) {
Config.Logger.LogInformation("Очень много запросов. Подождем...");
await Task.Delay(TimeSpan.FromSeconds(10));
continue;
Expand Down
2 changes: 1 addition & 1 deletion Core/Logic/Getters/Litnet/LitnetGetterBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ private async Task<IEnumerable<LitnetChapterResponse>> GetToc(string token, IEnu

private async Task<T> GetApiData<T>(Uri uri) {
var response = await Config.Client.SendAsync(GetDefaultMessage(uri, ApiUrl));
if (response.StatusCode == HttpStatusCode.TooManyRequests) {
if (response.StatusCode == HttpStatusCode.Forbidden) {
throw new Exception("Получен бан. Попробуйте позже.");
}

Expand Down

0 comments on commit 15eb34d

Please sign in to comment.