From c4468b9cbb5c98376e8c165d019cfe428419dd7a Mon Sep 17 00:00:00 2001 From: bakerboy448 <55419169+bakerboy448@users.noreply.github.com> Date: Mon, 24 Jan 2022 00:09:21 -0600 Subject: [PATCH] Fixed: (PTP) Treat 403 as Query Limit --- .../PassThePopcorn/PassThePopcornParser.cs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/NzbDrone.Core/Indexers/Definitions/PassThePopcorn/PassThePopcornParser.cs b/src/NzbDrone.Core/Indexers/Definitions/PassThePopcorn/PassThePopcornParser.cs index 7086788b0..46273b077 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/PassThePopcorn/PassThePopcornParser.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/PassThePopcorn/PassThePopcornParser.cs @@ -25,26 +25,32 @@ namespace NzbDrone.Core.Indexers.PassThePopcorn public IList ParseResponse(IndexerResponse indexerResponse) { var torrentInfos = new List(); + var indexerHttpResponse = indexerResponse.HttpResponse; - if (indexerResponse.HttpResponse.StatusCode != HttpStatusCode.OK) + if (indexerHttpResponse.StatusCode != HttpStatusCode.OK) { // Remove cookie cache - if (indexerResponse.HttpResponse.HasHttpRedirect && indexerResponse.HttpResponse.RedirectUrl + if (indexerHttpResponse.HasHttpRedirect && indexerHttpResponse.RedirectUrl .ContainsIgnoreCase("login.php")) { CookiesUpdater(null, null); - throw new IndexerException(indexerResponse, "We are being redirected to the PTP login page. Most likely your session expired or was killed. Try testing the indexer in the settings."); + throw new IndexerAuthException("We are being redirected to the PTP login page. Most likely your session expired or was killed. Try testing the indexer in the settings."); + } + + if (indexerHttpResponse.StatusCode == HttpStatusCode.Forbidden) + { + throw new RequestLimitReachedException(indexerResponse, "PTP Query Limit Reached. Please try again later."); } throw new IndexerException(indexerResponse, $"Unexpected response status {indexerResponse.HttpResponse.StatusCode} code from API request"); } - if (indexerResponse.HttpResponse.Headers.ContentType != HttpAccept.Json.Value) + if (indexerHttpResponse.Headers.ContentType != HttpAccept.Json.Value) { - if (indexerResponse.HttpResponse.Request.Url.Path.ContainsIgnoreCase("login.php")) + if (indexerHttpResponse.Request.Url.Path.ContainsIgnoreCase("login.php")) { CookiesUpdater(null, null); - throw new IndexerException(indexerResponse, "We are currently on the login page. Most likely your session expired or was killed. Try testing the indexer in the settings."); + throw new IndexerAuthException("We are currently on the login page. Most likely your session expired or was killed. Try testing the indexer in the settings."); } // Remove cookie cache