From 4d9982872a54ce044c0a18eb31aa7fcfc787c305 Mon Sep 17 00:00:00 2001 From: bakerboy448 <55419169+bakerboy448@users.noreply.github.com> Date: Thu, 4 Sep 2025 13:30:12 -0500 Subject: [PATCH] New: (PTP) Improve Error Handling --- .../Definitions/PassThePopcorn/PassThePopcornParser.cs | 10 ++++++++++ .../PassThePopcorn/PassThePopcornRequestGenerator.cs | 2 ++ 2 files changed, 12 insertions(+) diff --git a/src/NzbDrone.Core/Indexers/Definitions/PassThePopcorn/PassThePopcornParser.cs b/src/NzbDrone.Core/Indexers/Definitions/PassThePopcorn/PassThePopcornParser.cs index fa5791a62..6283e25e3 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/PassThePopcorn/PassThePopcornParser.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/PassThePopcorn/PassThePopcornParser.cs @@ -35,6 +35,16 @@ public IList ParseResponse(IndexerResponse indexerResponse) throw new RequestLimitReachedException(indexerResponse, "PTP Query Limit Reached. Please try again later."); } + if (httpResponse.StatusCode == HttpStatusCode.TooManyRequests && indexerResponse.Content.Contains("We are not a TV indexer")) + { + throw new IndexerException(indexerResponse, "Invalid indexer request: We are not a TV indexer", HttpStatusCode.BadRequest); + } + + if (httpResponse.StatusCode == HttpStatusCode.TooManyRequests) + { + throw new RequestLimitReachedException(indexerResponse, "PTP Request Limit Reached. Please try again later."); + } + throw new IndexerException(indexerResponse, $"Unexpected response status {indexerResponse.HttpResponse.StatusCode} code from indexer request"); } diff --git a/src/NzbDrone.Core/Indexers/Definitions/PassThePopcorn/PassThePopcornRequestGenerator.cs b/src/NzbDrone.Core/Indexers/Definitions/PassThePopcorn/PassThePopcornRequestGenerator.cs index 2cb8c1a96..e22a39c8b 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/PassThePopcorn/PassThePopcornRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/PassThePopcorn/PassThePopcornRequestGenerator.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Collections.Specialized; using System.Linq; +using System.Net; using NzbDrone.Common.Extensions; using NzbDrone.Common.Http; using NzbDrone.Core.IndexerSearch.Definitions; @@ -115,6 +116,7 @@ private IEnumerable GetRequest(string searchTerm, SearchCriteria var request = new IndexerRequest(searchUrl, HttpAccept.Json); request.HttpRequest.Headers.Add("ApiUser", _settings.APIUser); request.HttpRequest.Headers.Add("ApiKey", _settings.APIKey); + request.HttpRequest.SuppressHttpErrorStatusCodes = new[] { HttpStatusCode.TooManyRequests }; yield return request; }