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);
|
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());
|
||||||
|
|
||||||
@ -105,18 +99,24 @@ 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("/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();
|
app.Run();
|
||||||
|
|
||||||
class Settings
|
class Settings
|
||||||
{
|
{
|
||||||
public string downloadLocation { get; }
|
public string downloadLocation;
|
||||||
public Komga? komga { get; }
|
public Komga? komga;
|
||||||
|
|
||||||
public Settings(TaskManager.SettingsData settings)
|
public Settings(TaskManager.SettingsData settings)
|
||||||
{
|
{
|
||||||
this.downloadLocation = settings.downloadLocation;
|
this.downloadLocation = settings.downloadLocation;
|
||||||
this.komga = settings.komga;
|
this.komga = komga;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -21,8 +21,6 @@
|
|||||||
|
|
||||||
<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.UpdateSettings(pDownloadLocation: tmpPath, null);
|
settings.downloadLocation = tmpPath;
|
||||||
|
|
||||||
Console.WriteLine($"Komga BaseURL [{settings.komga?.baseUrl}]:");
|
Console.WriteLine($"Komga BaseURL [{settings.komga?.baseUrl}]:");
|
||||||
string? tmpUrl = Console.ReadLine();
|
string? tmpUrl = Console.ReadLine();
|
||||||
@ -73,8 +73,8 @@ public static class Tranga_Cli
|
|||||||
tmpPass += keyInfo.KeyChar;
|
tmpPass += keyInfo.KeyChar;
|
||||||
}
|
}
|
||||||
} while (key != ConsoleKey.Enter);
|
} 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.");
|
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.TryAdd(key, altTitleObject[key]!.GetValue<string>());
|
altTitlesDict.Add(key, altTitleObject[key]!.GetValue<string>());
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonArray tagsObject = attributes["tags"]!.AsArray();
|
JsonArray tagsObject = attributes["tags"]!.AsArray();
|
||||||
|
@ -43,15 +43,6 @@ 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;
|
||||||
@ -163,7 +154,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.TryAdd((Publication)publication!, new List<Chapter>());
|
_chapterCollection.Add((Publication)publication!, new List<Chapter>());
|
||||||
_allTasks.Add(newTask);
|
_allTasks.Add(newTask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -240,11 +231,8 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -320,9 +308,9 @@ public class TaskManager
|
|||||||
|
|
||||||
public class SettingsData
|
public class SettingsData
|
||||||
{
|
{
|
||||||
public string downloadLocation { get; private set; }
|
public string downloadLocation { get; set; }
|
||||||
public string settingsFilePath { get; }
|
public string settingsFilePath { get; }
|
||||||
public Komga? komga { get; private set; }
|
public Komga? komga { get; 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)
|
||||||
@ -334,13 +322,5 @@ 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