Compare commits
No commits in common. "cf171d5c381e515e9ace06838928438d60ccaf97" and "455c87b2e1875d1b116fb18990990942b7574fc7" have entirely different histories.
cf171d5c38
...
455c87b2e1
@ -25,14 +25,8 @@ else
|
||||
TaskManager taskManager = new (settings, logger);
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
builder.Services.AddControllers().AddNewtonsoftJson();
|
||||
var app = builder.Build();
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
|
||||
app.MapGet("/GetAvailableControllers", () => taskManager.GetAvailableConnectors());
|
||||
|
||||
@ -105,18 +99,24 @@ app.MapPost("/Queue/Dequeue", (string taskType, string? connectorName, string? p
|
||||
|
||||
app.MapGet("/Settings/Get", () => new Settings(taskManager.settings));
|
||||
|
||||
app.MapPost("/Settings/Update", (string? downloadLocation, string? komgaUrl, string? komgaAuth) => taskManager.UpdateSettings(downloadLocation, komgaUrl, komgaAuth) );
|
||||
app.MapPost("/Setting/Update", (string? downloadLocation, string? komgaUrl, string? komgaAuth) =>
|
||||
{
|
||||
if(downloadLocation is not null)
|
||||
taskManager.settings.downloadLocation = downloadLocation;
|
||||
if(komgaUrl is not null && komgaAuth is not null)
|
||||
taskManager.settings.komga = new Komga(komgaUrl, komgaAuth, logger);
|
||||
});
|
||||
|
||||
app.Run();
|
||||
|
||||
class Settings
|
||||
{
|
||||
public string downloadLocation { get; }
|
||||
public Komga? komga { get; }
|
||||
public string downloadLocation;
|
||||
public Komga? komga;
|
||||
|
||||
public Settings(TaskManager.SettingsData settings)
|
||||
{
|
||||
this.downloadLocation = settings.downloadLocation;
|
||||
this.komga = settings.komga;
|
||||
this.komga = komga;
|
||||
}
|
||||
}
|
@ -21,8 +21,6 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="7.0.5" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="7.0.6" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -41,7 +41,7 @@ public static class Tranga_Cli
|
||||
while(tmpPath is null)
|
||||
tmpPath = Console.ReadLine();
|
||||
if(tmpPath.Length > 0)
|
||||
settings.UpdateSettings(pDownloadLocation: tmpPath, null);
|
||||
settings.downloadLocation = tmpPath;
|
||||
|
||||
Console.WriteLine($"Komga BaseURL [{settings.komga?.baseUrl}]:");
|
||||
string? tmpUrl = Console.ReadLine();
|
||||
@ -73,8 +73,8 @@ public static class Tranga_Cli
|
||||
tmpPass += keyInfo.KeyChar;
|
||||
}
|
||||
} while (key != ConsoleKey.Enter);
|
||||
|
||||
settings.UpdateSettings(null, new Komga(tmpUrl, tmpUser, tmpPass, logger));
|
||||
|
||||
settings.komga = new Komga(tmpUrl, tmpUser, tmpPass, logger);
|
||||
}
|
||||
|
||||
logger.WriteLine("Tranga_CLI", "Loaded.");
|
||||
|
@ -63,7 +63,7 @@ public class MangaDex : Connector
|
||||
{
|
||||
JsonObject altTitleObject = (JsonObject)altTitleNode!;
|
||||
string key = ((IDictionary<string, JsonNode?>)altTitleObject).Keys.ToArray()[0];
|
||||
altTitlesDict.TryAdd(key, altTitleObject[key]!.GetValue<string>());
|
||||
altTitlesDict.Add(key, altTitleObject[key]!.GetValue<string>());
|
||||
}
|
||||
|
||||
JsonArray tagsObject = attributes["tags"]!.AsArray();
|
||||
|
@ -43,15 +43,6 @@ public class TaskManager
|
||||
taskChecker.Start();
|
||||
}
|
||||
|
||||
public void UpdateSettings(string? downloadLocation, string? komgaUrl, string? komgaAuth)
|
||||
{
|
||||
Komga? komga = null;
|
||||
if (komgaUrl is not null && komgaAuth is not null)
|
||||
komga = new Komga(komgaUrl, komgaAuth, null);
|
||||
settings.UpdateSettings(downloadLocation, komga);
|
||||
ExportData();
|
||||
}
|
||||
|
||||
public TaskManager(SettingsData settings, Logger? logger = null)
|
||||
{
|
||||
this.logger = logger;
|
||||
@ -163,7 +154,7 @@ public class TaskManager
|
||||
trangaTask.publication?.downloadUrl == publication?.downloadUrl))
|
||||
{
|
||||
if(task != TrangaTask.Task.UpdatePublications)
|
||||
_chapterCollection.TryAdd((Publication)publication!, new List<Chapter>());
|
||||
_chapterCollection.Add((Publication)publication!, new List<Chapter>());
|
||||
_allTasks.Add(newTask);
|
||||
}
|
||||
}
|
||||
@ -240,11 +231,8 @@ public class TaskManager
|
||||
public Publication[] GetPublicationsFromConnector(Connector connector, string? title = null)
|
||||
{
|
||||
Publication[] ret = connector.GetPublications(title ?? "");
|
||||
foreach (Publication publication in ret)
|
||||
{
|
||||
if(!_chapterCollection.Any(pub => pub.Key.sortName == publication.sortName))
|
||||
this._chapterCollection.TryAdd(publication, new List<Chapter>());
|
||||
}
|
||||
foreach(Publication publication in ret)
|
||||
this._chapterCollection.TryAdd(publication, new List<Chapter>());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -320,9 +308,9 @@ public class TaskManager
|
||||
|
||||
public class SettingsData
|
||||
{
|
||||
public string downloadLocation { get; private set; }
|
||||
public string downloadLocation { get; set; }
|
||||
public string settingsFilePath { get; }
|
||||
public Komga? komga { get; private set; }
|
||||
public Komga? komga { get; set; }
|
||||
public HashSet<TrangaTask> allTasks { get; }
|
||||
|
||||
public SettingsData(string downloadLocation, string? settingsFilePath, Komga? komga, HashSet<TrangaTask> allTasks)
|
||||
@ -334,13 +322,5 @@ public class TaskManager
|
||||
this.komga = komga;
|
||||
this.allTasks = allTasks;
|
||||
}
|
||||
|
||||
public void UpdateSettings(string? pDownloadLocation, Komga? pKomga)
|
||||
{
|
||||
if(pDownloadLocation is not null)
|
||||
this.downloadLocation = pDownloadLocation;
|
||||
if(pKomga is not null)
|
||||
this.komga = pKomga;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user