diff --git a/Tranga-API/Program.cs b/Tranga-API/Program.cs index 08915df..b54c925 100644 --- a/Tranga-API/Program.cs +++ b/Tranga-API/Program.cs @@ -10,9 +10,7 @@ app.MapGet("/GetConnectors", () => JsonSerializer.Serialize(taskManager.GetAvail app.MapGet("/GetPublications", (string connectorName, string? title) => { - Connector? connector = taskManager.GetAvailableConnectors().FirstOrDefault(c => c.Key == connectorName).Value; - if (connector is null) - return JsonSerializer.Serialize($"Connector {connectorName} is not a known connector."); + Connector connector = taskManager.GetConnector(connectorName); Publication[] publications; if (title is not null) diff --git a/Tranga-CLI/Tranga_Cli.cs b/Tranga-CLI/Tranga_Cli.cs index 7fda55a..8e36ef2 100644 --- a/Tranga-CLI/Tranga_Cli.cs +++ b/Tranga-CLI/Tranga_Cli.cs @@ -279,7 +279,7 @@ public static class Tranga_Cli private static void DownloadNow(TaskManager.SettingsData settings) { - Connector connector = SelectConnector(settings.downloadLocation); + Connector connector = SelectConnector(settings.downloadLocation, new Connector[]{new MangaDex(settings.downloadLocation)}); Publication publication = SelectPublication(connector); @@ -298,10 +298,9 @@ public static class Tranga_Cli } } - private static Connector SelectConnector(string folderPath, Connector[]? availableConnectors = null) + private static Connector SelectConnector(string folderPath, Connector[] connectors) { Console.Clear(); - Connector[] connectors = availableConnectors ?? new Connector[] { new MangaDex(folderPath) }; int cIndex = 0; Console.WriteLine("Connectors:"); diff --git a/Tranga/TaskExecutor.cs b/Tranga/TaskExecutor.cs index 82a4bbd..139890d 100644 --- a/Tranga/TaskExecutor.cs +++ b/Tranga/TaskExecutor.cs @@ -18,11 +18,7 @@ public static class TaskExecutor { Connector? connector = null; if (trangaTask.task != TrangaTask.Task.UpdateKomgaLibrary) - { - //Get Connector from list of available Connectors and the required Connector of the TrangaTask - if (!taskManager.GetAvailableConnectors().TryGetValue(trangaTask.connectorName, out connector)) - throw new ArgumentException($"Connector {trangaTask.connectorName} is not a known connector."); - } + connector = taskManager.GetConnector(trangaTask.connectorName!); if (trangaTask.isBeingExecuted) return;