2
0

Use GetConnector Method.

This commit is contained in:
glax 2023-05-20 14:21:47 +02:00
parent fa44de0c8d
commit 58de0115d6
3 changed files with 4 additions and 11 deletions

View File

@ -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)

View File

@ -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:");

View File

@ -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;