Fixed: Cleanup NetImport Implementation

pull/4072/head
Qstick 5 years ago
parent ba83c01b6c
commit 1c91c9939f

@ -77,17 +77,17 @@ namespace NzbDrone.Core.NetImport.CouchPotato
return movies; 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") && if (netImportResponse.HttpResponse.Headers.ContentType != null && netImportResponse.HttpResponse.Headers.ContentType.Contains("text/json") &&
indexerResponse.HttpRequest.Headers.Accept != null && !indexerResponse.HttpRequest.Headers.Accept.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; return true;

@ -49,11 +49,9 @@ namespace NzbDrone.Core.NetImport
yield return new NetImportDefinition yield return new NetImportDefinition
{ {
Name = Name, Name = GetType().Name,
Enabled = config.Validate().IsValid && Enabled, Enabled = config.Validate().IsValid && Enabled,
EnableAuto = true, EnableAuto = true,
ProfileId = 1,
MinimumAvailability = MovieStatusType.Announced,
Implementation = GetType().Name, Implementation = GetType().Name,
Settings = config Settings = config
}; };

@ -32,8 +32,7 @@ namespace NzbDrone.Core.NetImport
protected override List<NetImportDefinition> Active() protected override List<NetImportDefinition> 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().Where(c => c.Enabled).ToList();
return base.Active().ToList();
} }
public override void SetProviderCharacteristics(INetImport provider, NetImportDefinition definition) public override void SetProviderCharacteristics(INetImport provider, NetImportDefinition definition)

@ -3,13 +3,10 @@ using System.Linq;
using NLog; using NLog;
using NzbDrone.Common.Extensions; using NzbDrone.Common.Extensions;
using NzbDrone.Core.Configuration; using NzbDrone.Core.Configuration;
using NzbDrone.Core.Download;
using NzbDrone.Core.IndexerSearch;
using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.Messaging.Commands;
using NzbDrone.Core.MetadataSource; using NzbDrone.Core.MetadataSource;
using NzbDrone.Core.Movies; using NzbDrone.Core.Movies;
using NzbDrone.Core.NetImport.ImportExclusions; using NzbDrone.Core.NetImport.ImportExclusions;
using NzbDrone.Core.RootFolders;
namespace NzbDrone.Core.NetImport namespace NzbDrone.Core.NetImport
{ {
@ -25,18 +22,12 @@ namespace NzbDrone.Core.NetImport
private readonly INetImportFactory _netImportFactory; private readonly INetImportFactory _netImportFactory;
private readonly IMovieService _movieService; private readonly IMovieService _movieService;
private readonly ISearchForNewMovie _movieSearch; private readonly ISearchForNewMovie _movieSearch;
private readonly IRootFolderService _rootFolder;
private readonly IConfigService _configService; private readonly IConfigService _configService;
private readonly ISearchForNzb _nzbSearchService;
private readonly IProcessDownloadDecisions _processDownloadDecisions;
private readonly IImportExclusionsService _exclusionService; private readonly IImportExclusionsService _exclusionService;
public NetImportSearchService(INetImportFactory netImportFactory, public NetImportSearchService(INetImportFactory netImportFactory,
IMovieService movieService, IMovieService movieService,
ISearchForNewMovie movieSearch, ISearchForNewMovie movieSearch,
IRootFolderService rootFolder,
ISearchForNzb nzbSearchService,
IProcessDownloadDecisions processDownloadDecisions,
IConfigService configService, IConfigService configService,
IImportExclusionsService exclusionService, IImportExclusionsService exclusionService,
Logger logger) Logger logger)
@ -44,9 +35,6 @@ namespace NzbDrone.Core.NetImport
_netImportFactory = netImportFactory; _netImportFactory = netImportFactory;
_movieService = movieService; _movieService = movieService;
_movieSearch = movieSearch; _movieSearch = movieSearch;
_nzbSearchService = nzbSearchService;
_processDownloadDecisions = processDownloadDecisions;
_rootFolder = rootFolder;
_exclusionService = exclusionService; _exclusionService = exclusionService;
_logger = logger; _logger = logger;
_configService = configService; _configService = configService;

@ -105,17 +105,17 @@ namespace NzbDrone.Core.NetImport.RSSImport
return new Movie(); 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") && if (netImportResponse.HttpResponse.Headers.ContentType != null && netImportResponse.HttpResponse.Headers.ContentType.Contains("text/html") &&
indexerResponse.HttpRequest.Headers.Accept != null && !indexerResponse.HttpRequest.Headers.Accept.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; return true;

@ -42,11 +42,11 @@ namespace NzbDrone.Core.NetImport.Radarr
return jsonResponse.SelectList(_skyhookProxy.MapMovie); return jsonResponse.SelectList(_skyhookProxy.MapMovie);
} }
protected virtual bool PreProcess(NetImportResponse indexerResponse) protected virtual bool PreProcess(NetImportResponse netImportResponse)
{ {
try try
{ {
var error = JsonConvert.DeserializeObject<RadarrError>(indexerResponse.HttpResponse.Content); var error = JsonConvert.DeserializeObject<RadarrError>(netImportResponse.HttpResponse.Content);
if (error != null && error.Errors != null && error.Errors.Count != 0) if (error != null && error.Errors != null && error.Errors.Count != 0)
{ {
@ -58,9 +58,9 @@ namespace NzbDrone.Core.NetImport.Radarr
//No error! //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; return true;

@ -25,7 +25,7 @@ namespace NzbDrone.Core.NetImport.StevenLu
public override IParseNetImportResponse GetParser() public override IParseNetImportResponse GetParser()
{ {
return new StevenLuParser(Settings); return new StevenLuParser();
} }
} }
} }

@ -8,12 +8,10 @@ namespace NzbDrone.Core.NetImport.StevenLu
{ {
public class StevenLuParser : IParseNetImportResponse public class StevenLuParser : IParseNetImportResponse
{ {
private readonly StevenLuSettings _settings;
private NetImportResponse _importResponse; private NetImportResponse _importResponse;
public StevenLuParser(StevenLuSettings settings) public StevenLuParser()
{ {
_settings = settings;
} }
public IList<Movies.Movie> ParseResponse(NetImportResponse importResponse) public IList<Movies.Movie> ParseResponse(NetImportResponse importResponse)
@ -47,17 +45,17 @@ namespace NzbDrone.Core.NetImport.StevenLu
return movies; 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") && if (netImportResponse.HttpResponse.Headers.ContentType != null && netImportResponse.HttpResponse.Headers.ContentType.Contains("text/json") &&
indexerResponse.HttpRequest.Headers.Accept != null && !indexerResponse.HttpRequest.Headers.Accept.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; return true;

@ -67,17 +67,17 @@ namespace NzbDrone.Core.NetImport.Trakt
return movies; 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") && if (netImportResponse.HttpResponse.Headers.ContentType != null && netImportResponse.HttpResponse.Headers.ContentType.Contains("text/json") &&
indexerResponse.HttpRequest.Headers.Accept != null && !indexerResponse.HttpRequest.Headers.Accept.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; return true;

Loading…
Cancel
Save