From 0150988bcd0f4c17b46adcb89d5a295618b7d63d Mon Sep 17 00:00:00 2001 From: Robin Dadswell <19610103+RobinDadswell@users.noreply.github.com> Date: Fri, 4 Jun 2021 23:08:02 +0100 Subject: [PATCH] Added Indexer Factory --- .../Migration/JackettMigrationService.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/NzbDrone.Core/Migration/JackettMigrationService.cs b/src/NzbDrone.Core/Migration/JackettMigrationService.cs index 00c60bac5..eb89ef21c 100644 --- a/src/NzbDrone.Core/Migration/JackettMigrationService.cs +++ b/src/NzbDrone.Core/Migration/JackettMigrationService.cs @@ -6,24 +6,28 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; using NLog; using NzbDrone.Common.Http; +using NzbDrone.Core.Indexers; namespace NzbDrone.Core.Migration { public interface IJackettMigrationService { List GetJackettIndexers(string jackettPath, string jackettApi); - JackettIndexerConfigDefintion GetJackettIndexerConfig(JackettIndexerDefinition jackettIndexerDefinition, string jackettPath, string jackettApi); - void MigrateJackettIndexer(JackettIndexerDefinition jackettIndexer, JackettIndexerConfigDefintion jackettIndexerConfig); + List GetJackettIndexerConfig(JackettIndexerDefinition jackettIndexerDefinition, string jackettPath, string jackettApi); + void MigrateJackettIndexer(JackettIndexerDefinition jackettIndexer, List jackettIndexerConfig); } public class JackettMigrationService : IJackettMigrationService { + private readonly IIndexerFactory _indexerFactory; private readonly Logger _logger; public IHttpClient HttpClient { get; set; } public IHttpRequestBuilderFactory RequestBuilder { get; set; } - public JackettMigrationService(Logger logger) + + public JackettMigrationService(IIndexerFactory indexerFactory, Logger logger) { _logger = logger; + _indexerFactory = indexerFactory; } public List GetJackettIndexers(string jackettPath, string jackettApi) @@ -37,18 +41,18 @@ namespace NzbDrone.Core.Migration return jsonResponse; } - public JackettIndexerConfigDefintion GetJackettIndexerConfig(JackettIndexerDefinition jackettIndexerDefinition, string jackettPath, string jackettApi) + public List GetJackettIndexerConfig(JackettIndexerDefinition jackettIndexerDefinition, string jackettPath, string jackettApi) { _logger.Debug($"Getting config from Jackett for {jackettIndexerDefinition.Name}"); var requestBuilder = BuildRequest(jackettPath, jackettApi, jackettIndexerDefinition.Id); - var jsonResponse = JsonConvert.DeserializeObject(HttpClient.Execute(requestBuilder.Build()).Content); + var jsonResponse = JsonConvert.DeserializeObject>(HttpClient.Execute(requestBuilder.Build()).Content); return jsonResponse; } - public void MigrateJackettIndexer(JackettIndexerDefinition jackettIndexer, JackettIndexerConfigDefintion jackettIndexerConfig) + public void MigrateJackettIndexer(JackettIndexerDefinition jackettIndexer, List jackettIndexerConfig) { _logger.Info($"Creating {jackettIndexer.Name} in Prowlarr");