Added Indexer Factory

jackettmigration
Robin Dadswell 4 years ago
parent 593231c3af
commit 0150988bcd

@ -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<JackettIndexerDefinition> GetJackettIndexers(string jackettPath, string jackettApi);
JackettIndexerConfigDefintion GetJackettIndexerConfig(JackettIndexerDefinition jackettIndexerDefinition, string jackettPath, string jackettApi);
void MigrateJackettIndexer(JackettIndexerDefinition jackettIndexer, JackettIndexerConfigDefintion jackettIndexerConfig);
List<JackettIndexerConfigDefintion> GetJackettIndexerConfig(JackettIndexerDefinition jackettIndexerDefinition, string jackettPath, string jackettApi);
void MigrateJackettIndexer(JackettIndexerDefinition jackettIndexer, List<JackettIndexerConfigDefintion> 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<JackettIndexerDefinition> 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<JackettIndexerConfigDefintion> 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<JackettIndexerConfigDefintion>(HttpClient.Execute(requestBuilder.Build()).Content);
var jsonResponse = JsonConvert.DeserializeObject<List<JackettIndexerConfigDefintion>>(HttpClient.Execute(requestBuilder.Build()).Content);
return jsonResponse;
}
public void MigrateJackettIndexer(JackettIndexerDefinition jackettIndexer, JackettIndexerConfigDefintion jackettIndexerConfig)
public void MigrateJackettIndexer(JackettIndexerDefinition jackettIndexer, List<JackettIndexerConfigDefintion> jackettIndexerConfig)
{
_logger.Info($"Creating {jackettIndexer.Name} in Prowlarr");

Loading…
Cancel
Save