Compare commits
10 Commits
455c87b2e1
...
cf171d5c38
Author | SHA1 | Date | |
---|---|---|---|
cf171d5c38 | |||
6d49b4b934 | |||
b55d2a2d06 | |||
737eebf599 | |||
aef01b684c | |||
53bff61174 | |||
431a602a40 | |||
9afb81cee2 | |||
ea69b355b5 | |||
84dbc36bbf |
@ -25,8 +25,14 @@ else
|
|||||||
TaskManager taskManager = new (settings, logger);
|
TaskManager taskManager = new (settings, logger);
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
builder.Services.AddEndpointsApiExplorer();
|
||||||
|
builder.Services.AddSwaggerGen();
|
||||||
builder.Services.AddControllers().AddNewtonsoftJson();
|
builder.Services.AddControllers().AddNewtonsoftJson();
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
app.UseSwagger();
|
||||||
|
app.UseSwaggerUI();
|
||||||
|
app.UseSwagger();
|
||||||
|
app.UseSwaggerUI();
|
||||||
|
|
||||||
app.MapGet("/GetAvailableControllers", () => taskManager.GetAvailableConnectors());
|
app.MapGet("/GetAvailableControllers", () => taskManager.GetAvailableConnectors());
|
||||||
|
|
||||||
@ -99,24 +105,18 @@ app.MapPost("/Queue/Dequeue", (string taskType, string? connectorName, string? p
|
|||||||
|
|
||||||
app.MapGet("/Settings/Get", () => new Settings(taskManager.settings));
|
app.MapGet("/Settings/Get", () => new Settings(taskManager.settings));
|
||||||
|
|
||||||
app.MapPost("/Setting/Update", (string? downloadLocation, string? komgaUrl, string? komgaAuth) =>
|
app.MapPost("/Settings/Update", (string? downloadLocation, string? komgaUrl, string? komgaAuth) => taskManager.UpdateSettings(downloadLocation, komgaUrl, 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();
|
app.Run();
|
||||||
|
|
||||||
class Settings
|
class Settings
|
||||||
{
|
{
|
||||||
public string downloadLocation;
|
public string downloadLocation { get; }
|
||||||
public Komga? komga;
|
public Komga? komga { get; }
|
||||||
|
|
||||||
public Settings(TaskManager.SettingsData settings)
|
public Settings(TaskManager.SettingsData settings)
|
||||||
{
|
{
|
||||||
this.downloadLocation = settings.downloadLocation;
|
this.downloadLocation = settings.downloadLocation;
|
||||||
this.komga = komga;
|
this.komga = settings.komga;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="7.0.5" />
|
<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>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -41,7 +41,7 @@ public static class Tranga_Cli
|
|||||||
while(tmpPath is null)
|
while(tmpPath is null)
|
||||||
tmpPath = Console.ReadLine();
|
tmpPath = Console.ReadLine();
|
||||||
if(tmpPath.Length > 0)
|
if(tmpPath.Length > 0)
|
||||||
settings.downloadLocation = tmpPath;
|
settings.UpdateSettings(pDownloadLocation: tmpPath, null);
|
||||||
|
|
||||||
Console.WriteLine($"Komga BaseURL [{settings.komga?.baseUrl}]:");
|
Console.WriteLine($"Komga BaseURL [{settings.komga?.baseUrl}]:");
|
||||||
string? tmpUrl = Console.ReadLine();
|
string? tmpUrl = Console.ReadLine();
|
||||||
@ -74,7 +74,7 @@ public static class Tranga_Cli
|
|||||||
}
|
}
|
||||||
} while (key != ConsoleKey.Enter);
|
} while (key != ConsoleKey.Enter);
|
||||||
|
|
||||||
settings.komga = new Komga(tmpUrl, tmpUser, tmpPass, logger);
|
settings.UpdateSettings(null, new Komga(tmpUrl, tmpUser, tmpPass, logger));
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.WriteLine("Tranga_CLI", "Loaded.");
|
logger.WriteLine("Tranga_CLI", "Loaded.");
|
||||||
|
@ -63,7 +63,7 @@ public class MangaDex : Connector
|
|||||||
{
|
{
|
||||||
JsonObject altTitleObject = (JsonObject)altTitleNode!;
|
JsonObject altTitleObject = (JsonObject)altTitleNode!;
|
||||||
string key = ((IDictionary<string, JsonNode?>)altTitleObject).Keys.ToArray()[0];
|
string key = ((IDictionary<string, JsonNode?>)altTitleObject).Keys.ToArray()[0];
|
||||||
altTitlesDict.Add(key, altTitleObject[key]!.GetValue<string>());
|
altTitlesDict.TryAdd(key, altTitleObject[key]!.GetValue<string>());
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonArray tagsObject = attributes["tags"]!.AsArray();
|
JsonArray tagsObject = attributes["tags"]!.AsArray();
|
||||||
|
@ -43,6 +43,15 @@ public class TaskManager
|
|||||||
taskChecker.Start();
|
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)
|
public TaskManager(SettingsData settings, Logger? logger = null)
|
||||||
{
|
{
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
@ -154,7 +163,7 @@ public class TaskManager
|
|||||||
trangaTask.publication?.downloadUrl == publication?.downloadUrl))
|
trangaTask.publication?.downloadUrl == publication?.downloadUrl))
|
||||||
{
|
{
|
||||||
if(task != TrangaTask.Task.UpdatePublications)
|
if(task != TrangaTask.Task.UpdatePublications)
|
||||||
_chapterCollection.Add((Publication)publication!, new List<Chapter>());
|
_chapterCollection.TryAdd((Publication)publication!, new List<Chapter>());
|
||||||
_allTasks.Add(newTask);
|
_allTasks.Add(newTask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -231,8 +240,11 @@ public class TaskManager
|
|||||||
public Publication[] GetPublicationsFromConnector(Connector connector, string? title = null)
|
public Publication[] GetPublicationsFromConnector(Connector connector, string? title = null)
|
||||||
{
|
{
|
||||||
Publication[] ret = connector.GetPublications(title ?? "");
|
Publication[] ret = connector.GetPublications(title ?? "");
|
||||||
foreach(Publication publication in ret)
|
foreach (Publication publication in ret)
|
||||||
this._chapterCollection.TryAdd(publication, new List<Chapter>());
|
{
|
||||||
|
if(!_chapterCollection.Any(pub => pub.Key.sortName == publication.sortName))
|
||||||
|
this._chapterCollection.TryAdd(publication, new List<Chapter>());
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,9 +320,9 @@ public class TaskManager
|
|||||||
|
|
||||||
public class SettingsData
|
public class SettingsData
|
||||||
{
|
{
|
||||||
public string downloadLocation { get; set; }
|
public string downloadLocation { get; private set; }
|
||||||
public string settingsFilePath { get; }
|
public string settingsFilePath { get; }
|
||||||
public Komga? komga { get; set; }
|
public Komga? komga { get; private set; }
|
||||||
public HashSet<TrangaTask> allTasks { get; }
|
public HashSet<TrangaTask> allTasks { get; }
|
||||||
|
|
||||||
public SettingsData(string downloadLocation, string? settingsFilePath, Komga? komga, HashSet<TrangaTask> allTasks)
|
public SettingsData(string downloadLocation, string? settingsFilePath, Komga? komga, HashSet<TrangaTask> allTasks)
|
||||||
@ -322,5 +334,13 @@ public class TaskManager
|
|||||||
this.komga = komga;
|
this.komga = komga;
|
||||||
this.allTasks = allTasks;
|
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