From 1c91c9939fae5a9ad97161be23d7ba81904e4e81 Mon Sep 17 00:00:00 2001 From: Qstick Date: Sat, 2 Nov 2019 17:55:55 -0400 Subject: [PATCH] Fixed: Cleanup NetImport Implementation --- .../NetImport/CouchPotato/CouchPotatoParser.cs | 12 ++++++------ src/NzbDrone.Core/NetImport/NetImportBase.cs | 4 +--- src/NzbDrone.Core/NetImport/NetImportFactory.cs | 3 +-- .../NetImport/NetImportSearchService.cs | 12 ------------ .../NetImport/RSSImport/RSSImportParser.cs | 12 ++++++------ .../NetImport/Radarr/RadarrParser.cs | 8 ++++---- .../NetImport/StevenLu/StevenLuImport.cs | 2 +- .../NetImport/StevenLu/StevenLuParser.cs | 16 +++++++--------- src/NzbDrone.Core/NetImport/Trakt/TraktParser.cs | 12 ++++++------ 9 files changed, 32 insertions(+), 49 deletions(-) diff --git a/src/NzbDrone.Core/NetImport/CouchPotato/CouchPotatoParser.cs b/src/NzbDrone.Core/NetImport/CouchPotato/CouchPotatoParser.cs index bdbd399e6..2a1784cb0 100644 --- a/src/NzbDrone.Core/NetImport/CouchPotato/CouchPotatoParser.cs +++ b/src/NzbDrone.Core/NetImport/CouchPotato/CouchPotatoParser.cs @@ -77,17 +77,17 @@ namespace NzbDrone.Core.NetImport.CouchPotato return movies; } - protected virtual bool PreProcess(NetImportResponse indexerResponse) + protected virtual bool PreProcess(NetImportResponse netImportResponse) { - if (indexerResponse.HttpResponse.StatusCode != HttpStatusCode.OK) + if (netImportResponse.HttpResponse.StatusCode != HttpStatusCode.OK) { - throw new NetImportException(indexerResponse, "Indexer API call resulted in an unexpected StatusCode [{0}]", indexerResponse.HttpResponse.StatusCode); + throw new NetImportException(netImportResponse, "List API call resulted in an unexpected StatusCode [{0}]", netImportResponse.HttpResponse.StatusCode); } - if (indexerResponse.HttpResponse.Headers.ContentType != null && indexerResponse.HttpResponse.Headers.ContentType.Contains("text/json") && - indexerResponse.HttpRequest.Headers.Accept != null && !indexerResponse.HttpRequest.Headers.Accept.Contains("text/json")) + if (netImportResponse.HttpResponse.Headers.ContentType != null && netImportResponse.HttpResponse.Headers.ContentType.Contains("text/json") && + netImportResponse.HttpRequest.Headers.Accept != null && !netImportResponse.HttpRequest.Headers.Accept.Contains("text/json")) { - throw new NetImportException(indexerResponse, "Indexer responded with html content. Site is likely blocked or unavailable."); + throw new NetImportException(netImportResponse, "List responded with html content. Site is likely blocked or unavailable."); } return true; diff --git a/src/NzbDrone.Core/NetImport/NetImportBase.cs b/src/NzbDrone.Core/NetImport/NetImportBase.cs index 17bb41356..70f973650 100644 --- a/src/NzbDrone.Core/NetImport/NetImportBase.cs +++ b/src/NzbDrone.Core/NetImport/NetImportBase.cs @@ -49,11 +49,9 @@ namespace NzbDrone.Core.NetImport yield return new NetImportDefinition { - Name = Name, + Name = GetType().Name, Enabled = config.Validate().IsValid && Enabled, EnableAuto = true, - ProfileId = 1, - MinimumAvailability = MovieStatusType.Announced, Implementation = GetType().Name, Settings = config }; diff --git a/src/NzbDrone.Core/NetImport/NetImportFactory.cs b/src/NzbDrone.Core/NetImport/NetImportFactory.cs index 963d4e323..4975dcbae 100644 --- a/src/NzbDrone.Core/NetImport/NetImportFactory.cs +++ b/src/NzbDrone.Core/NetImport/NetImportFactory.cs @@ -32,8 +32,7 @@ namespace NzbDrone.Core.NetImport protected override List Active() { - // return base.Active().Where(c => c.Enabled).ToList(); // use this for when/if we add a setting to enable/disable lists - return base.Active().ToList(); + return base.Active().Where(c => c.Enabled).ToList(); } public override void SetProviderCharacteristics(INetImport provider, NetImportDefinition definition) diff --git a/src/NzbDrone.Core/NetImport/NetImportSearchService.cs b/src/NzbDrone.Core/NetImport/NetImportSearchService.cs index 2bcbb2be3..4c22caa99 100644 --- a/src/NzbDrone.Core/NetImport/NetImportSearchService.cs +++ b/src/NzbDrone.Core/NetImport/NetImportSearchService.cs @@ -3,13 +3,10 @@ using System.Linq; using NLog; using NzbDrone.Common.Extensions; using NzbDrone.Core.Configuration; -using NzbDrone.Core.Download; -using NzbDrone.Core.IndexerSearch; using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.MetadataSource; using NzbDrone.Core.Movies; using NzbDrone.Core.NetImport.ImportExclusions; -using NzbDrone.Core.RootFolders; namespace NzbDrone.Core.NetImport { @@ -25,18 +22,12 @@ namespace NzbDrone.Core.NetImport private readonly INetImportFactory _netImportFactory; private readonly IMovieService _movieService; private readonly ISearchForNewMovie _movieSearch; - private readonly IRootFolderService _rootFolder; private readonly IConfigService _configService; - private readonly ISearchForNzb _nzbSearchService; - private readonly IProcessDownloadDecisions _processDownloadDecisions; private readonly IImportExclusionsService _exclusionService; public NetImportSearchService(INetImportFactory netImportFactory, IMovieService movieService, ISearchForNewMovie movieSearch, - IRootFolderService rootFolder, - ISearchForNzb nzbSearchService, - IProcessDownloadDecisions processDownloadDecisions, IConfigService configService, IImportExclusionsService exclusionService, Logger logger) @@ -44,9 +35,6 @@ namespace NzbDrone.Core.NetImport _netImportFactory = netImportFactory; _movieService = movieService; _movieSearch = movieSearch; - _nzbSearchService = nzbSearchService; - _processDownloadDecisions = processDownloadDecisions; - _rootFolder = rootFolder; _exclusionService = exclusionService; _logger = logger; _configService = configService; diff --git a/src/NzbDrone.Core/NetImport/RSSImport/RSSImportParser.cs b/src/NzbDrone.Core/NetImport/RSSImport/RSSImportParser.cs index 0e1df0b9c..1ae8acd72 100644 --- a/src/NzbDrone.Core/NetImport/RSSImport/RSSImportParser.cs +++ b/src/NzbDrone.Core/NetImport/RSSImport/RSSImportParser.cs @@ -105,17 +105,17 @@ namespace NzbDrone.Core.NetImport.RSSImport return new Movie(); } - protected virtual bool PreProcess(NetImportResponse indexerResponse) + protected virtual bool PreProcess(NetImportResponse netImportResponse) { - if (indexerResponse.HttpResponse.StatusCode != HttpStatusCode.OK) + if (netImportResponse.HttpResponse.StatusCode != HttpStatusCode.OK) { - throw new NetImportException(indexerResponse, "Indexer API call resulted in an unexpected StatusCode [{0}]", indexerResponse.HttpResponse.StatusCode); + throw new NetImportException(netImportResponse, "List API call resulted in an unexpected StatusCode [{0}]", netImportResponse.HttpResponse.StatusCode); } - if (indexerResponse.HttpResponse.Headers.ContentType != null && indexerResponse.HttpResponse.Headers.ContentType.Contains("text/html") && - indexerResponse.HttpRequest.Headers.Accept != null && !indexerResponse.HttpRequest.Headers.Accept.Contains("text/html")) + if (netImportResponse.HttpResponse.Headers.ContentType != null && netImportResponse.HttpResponse.Headers.ContentType.Contains("text/html") && + netImportResponse.HttpRequest.Headers.Accept != null && !netImportResponse.HttpRequest.Headers.Accept.Contains("text/html")) { - throw new NetImportException(indexerResponse, "Indexer responded with html content. Site is likely blocked or unavailable."); + throw new NetImportException(netImportResponse, "List responded with html content. Site is likely blocked or unavailable."); } return true; diff --git a/src/NzbDrone.Core/NetImport/Radarr/RadarrParser.cs b/src/NzbDrone.Core/NetImport/Radarr/RadarrParser.cs index fad9f082e..fc0205b2c 100644 --- a/src/NzbDrone.Core/NetImport/Radarr/RadarrParser.cs +++ b/src/NzbDrone.Core/NetImport/Radarr/RadarrParser.cs @@ -42,11 +42,11 @@ namespace NzbDrone.Core.NetImport.Radarr return jsonResponse.SelectList(_skyhookProxy.MapMovie); } - protected virtual bool PreProcess(NetImportResponse indexerResponse) + protected virtual bool PreProcess(NetImportResponse netImportResponse) { try { - var error = JsonConvert.DeserializeObject(indexerResponse.HttpResponse.Content); + var error = JsonConvert.DeserializeObject(netImportResponse.HttpResponse.Content); if (error != null && error.Errors != null && error.Errors.Count != 0) { @@ -58,9 +58,9 @@ namespace NzbDrone.Core.NetImport.Radarr //No error! } - if (indexerResponse.HttpResponse.StatusCode != System.Net.HttpStatusCode.OK) + if (netImportResponse.HttpResponse.StatusCode != System.Net.HttpStatusCode.OK) { - throw new HttpException(indexerResponse.HttpRequest, indexerResponse.HttpResponse); + throw new HttpException(netImportResponse.HttpRequest, netImportResponse.HttpResponse); } return true; diff --git a/src/NzbDrone.Core/NetImport/StevenLu/StevenLuImport.cs b/src/NzbDrone.Core/NetImport/StevenLu/StevenLuImport.cs index a3071cd91..a774b5518 100644 --- a/src/NzbDrone.Core/NetImport/StevenLu/StevenLuImport.cs +++ b/src/NzbDrone.Core/NetImport/StevenLu/StevenLuImport.cs @@ -25,7 +25,7 @@ namespace NzbDrone.Core.NetImport.StevenLu public override IParseNetImportResponse GetParser() { - return new StevenLuParser(Settings); + return new StevenLuParser(); } } } diff --git a/src/NzbDrone.Core/NetImport/StevenLu/StevenLuParser.cs b/src/NzbDrone.Core/NetImport/StevenLu/StevenLuParser.cs index 47d6e9862..859aa52de 100644 --- a/src/NzbDrone.Core/NetImport/StevenLu/StevenLuParser.cs +++ b/src/NzbDrone.Core/NetImport/StevenLu/StevenLuParser.cs @@ -8,12 +8,10 @@ namespace NzbDrone.Core.NetImport.StevenLu { public class StevenLuParser : IParseNetImportResponse { - private readonly StevenLuSettings _settings; private NetImportResponse _importResponse; - public StevenLuParser(StevenLuSettings settings) + public StevenLuParser() { - _settings = settings; } public IList ParseResponse(NetImportResponse importResponse) @@ -47,17 +45,17 @@ namespace NzbDrone.Core.NetImport.StevenLu return movies; } - protected virtual bool PreProcess(NetImportResponse indexerResponse) + protected virtual bool PreProcess(NetImportResponse netImportResponse) { - if (indexerResponse.HttpResponse.StatusCode != HttpStatusCode.OK) + if (netImportResponse.HttpResponse.StatusCode != HttpStatusCode.OK) { - throw new NetImportException(indexerResponse, "Indexer API call resulted in an unexpected StatusCode [{0}]", indexerResponse.HttpResponse.StatusCode); + throw new NetImportException(netImportResponse, "StevenLu API call resulted in an unexpected StatusCode [{0}]", netImportResponse.HttpResponse.StatusCode); } - if (indexerResponse.HttpResponse.Headers.ContentType != null && indexerResponse.HttpResponse.Headers.ContentType.Contains("text/json") && - indexerResponse.HttpRequest.Headers.Accept != null && !indexerResponse.HttpRequest.Headers.Accept.Contains("text/json")) + if (netImportResponse.HttpResponse.Headers.ContentType != null && netImportResponse.HttpResponse.Headers.ContentType.Contains("text/json") && + netImportResponse.HttpRequest.Headers.Accept != null && !netImportResponse.HttpRequest.Headers.Accept.Contains("text/json")) { - throw new NetImportException(indexerResponse, "Indexer responded with html content. Site is likely blocked or unavailable."); + throw new NetImportException(netImportResponse, "StevenLu responded with html content. Site is likely blocked or unavailable."); } return true; diff --git a/src/NzbDrone.Core/NetImport/Trakt/TraktParser.cs b/src/NzbDrone.Core/NetImport/Trakt/TraktParser.cs index 72bde7be5..3b19a2cc1 100644 --- a/src/NzbDrone.Core/NetImport/Trakt/TraktParser.cs +++ b/src/NzbDrone.Core/NetImport/Trakt/TraktParser.cs @@ -67,17 +67,17 @@ namespace NzbDrone.Core.NetImport.Trakt return movies; } - protected virtual bool PreProcess(NetImportResponse indexerResponse) + protected virtual bool PreProcess(NetImportResponse netImportResponse) { - if (indexerResponse.HttpResponse.StatusCode != HttpStatusCode.OK) + if (netImportResponse.HttpResponse.StatusCode != HttpStatusCode.OK) { - throw new NetImportException(indexerResponse, "Indexer API call resulted in an unexpected StatusCode [{0}]", indexerResponse.HttpResponse.StatusCode); + throw new NetImportException(netImportResponse, "Trakt API call resulted in an unexpected StatusCode [{0}]", netImportResponse.HttpResponse.StatusCode); } - if (indexerResponse.HttpResponse.Headers.ContentType != null && indexerResponse.HttpResponse.Headers.ContentType.Contains("text/json") && - indexerResponse.HttpRequest.Headers.Accept != null && !indexerResponse.HttpRequest.Headers.Accept.Contains("text/json")) + if (netImportResponse.HttpResponse.Headers.ContentType != null && netImportResponse.HttpResponse.Headers.ContentType.Contains("text/json") && + netImportResponse.HttpRequest.Headers.Accept != null && !netImportResponse.HttpRequest.Headers.Accept.Contains("text/json")) { - throw new NetImportException(indexerResponse, "Indexer responded with html content. Site is likely blocked or unavailable."); + throw new NetImportException(netImportResponse, "Trakt API responded with html content. Site is likely blocked or unavailable."); } return true;