mirror of
https://github.com/C9Glax/tranga.git
synced 2025-06-14 07:17:54 +02:00
Compare commits
87 Commits
Author | SHA1 | Date | |
---|---|---|---|
79928075b0 | |||
9b8eb6a197 | |||
1d263ef45a | |||
e0877add30 | |||
046cad8072 | |||
b2ce55be96 | |||
a6e9013495 | |||
14c69631a6 | |||
ccc4e42a49 | |||
d6e75fda31 | |||
fc89537f63 | |||
fd3423d03c | |||
878f77766f | |||
08001fd684 | |||
e2917d2f2e | |||
32dc58715e | |||
add0583776 | |||
6fed0e5473 | |||
a0636ac7a2 | |||
7aeb78e2f6 | |||
5cf512f2b2 | |||
7d96b0901f | |||
68e80bc066 | |||
ad971fb065 | |||
86052472bc | |||
ec30bb40fa | |||
2fa96e9793 | |||
78e44b7704 | |||
8bf9df4419 | |||
4bd54f096d | |||
877daf0a1e | |||
6d0fcc13fb | |||
f0256494fd | |||
39fa905733 | |||
c557389967 | |||
201773af50 | |||
f85e02fb0a | |||
73d98b9c0f | |||
b0ee888c82 | |||
5c4431778e | |||
ccfa213b77 | |||
22d6389d38 | |||
f53dfb0822 | |||
a966bd788d | |||
dd651adc15 | |||
ba5ae67aa7 | |||
da4a5bed09 | |||
947b521163 | |||
5674adbd5e | |||
290819de09 | |||
0d0b68a8f9 | |||
87d2357b41 | |||
e3186aebb0 | |||
1cd37e2b1b | |||
9c267f395f | |||
e2b8888130 | |||
b6ac2682f6 | |||
eddf50483f | |||
a71d65e666 | |||
9a640aed27 | |||
30b6c4680b | |||
7b6253de0f | |||
5aa3214ce5 | |||
9b70994f71 | |||
93cf341f2d | |||
01cb74c088 | |||
ec480dffad | |||
b7014cbff5 | |||
0cab921402 | |||
0e0ba1796e | |||
27d8565dc1 | |||
79dc44d707 | |||
bb6a0ad0d4 | |||
43db463ba6 | |||
9eb8ddbc40 | |||
972cba69ec | |||
962fe9529e | |||
da1b0cb1cd | |||
7f88e57e47 | |||
8865bf284f | |||
5fc2de5fcb | |||
4bae223d95 | |||
0486168b43 | |||
b64ab5c6d4 | |||
578fa5e6be | |||
4d33e78123 | |||
52ac3e4e4e |
4
.gitignore
vendored
4
.gitignore
vendored
@ -16,4 +16,6 @@ riderModule.iml
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
/.idea
|
||||
/.idea
|
||||
cover.jpg
|
||||
cover.png
|
15
Dockerfile
Normal file
15
Dockerfile
Normal file
@ -0,0 +1,15 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/sdk:7.0 as build-env
|
||||
WORKDIR /src
|
||||
COPY . /src/
|
||||
RUN ls /src
|
||||
RUN dotnet restore Tranga-API/Tranga-API.csproj
|
||||
RUN dotnet publish -c Release -o /publish
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:7.0 as runtime
|
||||
WORKDIR /publish
|
||||
COPY --from=build-env /publish .
|
||||
RUN ls /publish
|
||||
EXPOSE 80
|
||||
ENTRYPOINT ["dotnet", "/publish/Tranga-API.dll"]
|
@ -52,7 +52,7 @@ public abstract class LoggerBase : TextWriter
|
||||
public override string ToString()
|
||||
{
|
||||
string dateTimeString = $"{logTime.ToShortDateString()} {logTime.ToLongTimeString()}";
|
||||
return $"[{dateTimeString}] {caller,30} | {value}";
|
||||
return $"[{dateTimeString}] {caller.Split(new char[]{'.','+'}).Last(),15} | {value}";
|
||||
}
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
|
||||
WORKDIR /app
|
||||
EXPOSE 80
|
||||
EXPOSE 443
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
|
||||
WORKDIR /src
|
||||
COPY ["Tranga-API/Tranga-API.csproj", "Tranga-API/"]
|
||||
RUN dotnet restore "Tranga-API/Tranga-API.csproj"
|
||||
COPY . .
|
||||
WORKDIR "/src/Tranga-API"
|
||||
RUN dotnet build "Tranga-API.csproj" -c Release -o /app/build
|
||||
|
||||
FROM build AS publish
|
||||
RUN dotnet publish "Tranga-API.csproj" -c Release -o /app/publish /p:UseAppHost=false
|
||||
|
||||
FROM base AS final
|
||||
WORKDIR /app
|
||||
COPY --from=publish /app/publish .
|
||||
ENTRYPOINT ["dotnet", "Tranga-API.dll"]
|
@ -1,26 +1,30 @@
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
using Logging;
|
||||
using Tranga;
|
||||
|
||||
string applicationFolderPath = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Tranga-API");
|
||||
string logsFolderPath = Path.Join(applicationFolderPath, "logs");
|
||||
string applicationFolderPath = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Tranga-API");
|
||||
string downloadFolderPath = RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? "/Manga" : Path.Join(applicationFolderPath, "Manga");
|
||||
string logsFolderPath = RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? "/var/logs/Tranga" : Path.Join(applicationFolderPath, "logs");
|
||||
string logFilePath = Path.Join(logsFolderPath, $"log-{DateTime.Now:dd-M-yyyy-HH-mm-ss}.txt");
|
||||
string settingsFilePath = Path.Join(applicationFolderPath, "data.json");
|
||||
string settingsFilePath = Path.Join(applicationFolderPath, "settings.json");
|
||||
|
||||
Directory.CreateDirectory(applicationFolderPath);
|
||||
Directory.CreateDirectory(downloadFolderPath);
|
||||
Directory.CreateDirectory(logsFolderPath);
|
||||
|
||||
|
||||
Console.WriteLine($"Application-Folder: {applicationFolderPath}");
|
||||
Console.WriteLine($"Download-Folder-Path: {downloadFolderPath}");
|
||||
Console.WriteLine($"Logfile-Path: {logFilePath}");
|
||||
Console.WriteLine($"Settings-File-Path: {settingsFilePath}");
|
||||
|
||||
Logger logger = new(new[] { Logger.LoggerType.FileLogger }, null, null, logFilePath);
|
||||
Logger logger = new(new[] { Logger.LoggerType.FileLogger, Logger.LoggerType.ConsoleLogger }, Console.Out, Console.Out.Encoding, logFilePath);
|
||||
|
||||
logger.WriteLine("Tranga_CLI", "Loading Taskmanager.");
|
||||
TaskManager.SettingsData settings;
|
||||
TrangaSettings settings;
|
||||
if (File.Exists(settingsFilePath))
|
||||
settings = TaskManager.LoadData(settingsFilePath);
|
||||
settings = TrangaSettings.LoadSettings(settingsFilePath);
|
||||
else
|
||||
settings = new TaskManager.SettingsData(Directory.GetCurrentDirectory(), settingsFilePath, null, new HashSet<TrangaTask>());
|
||||
settings = new TrangaSettings(downloadFolderPath, applicationFolderPath, null);
|
||||
|
||||
TaskManager taskManager = new (settings, logger);
|
||||
|
||||
@ -28,17 +32,31 @@ var builder = WebApplication.CreateBuilder(args);
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
builder.Services.AddControllers().AddNewtonsoftJson();
|
||||
|
||||
string corsHeader = "Tranga";
|
||||
builder.Services.AddCors(options =>
|
||||
{
|
||||
options.AddPolicy(name: corsHeader,
|
||||
policy =>
|
||||
{
|
||||
policy.AllowAnyOrigin();
|
||||
policy.WithMethods("GET", "POST", "DELETE");
|
||||
});
|
||||
});
|
||||
|
||||
var app = builder.Build();
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
|
||||
app.MapGet("/GetAvailableControllers", () => taskManager.GetAvailableConnectors());
|
||||
app.UseCors(corsHeader);
|
||||
|
||||
app.MapGet("/GetKnownPublications", () => taskManager.GetAllPublications());
|
||||
app.MapGet("/Tranga/GetAvailableControllers", () => taskManager.GetAvailableConnectors().Keys.ToArray());
|
||||
|
||||
app.MapGet("/GetPublicationsFromConnector", (string connectorName, string title) =>
|
||||
app.MapGet("/Tranga/GetKnownPublications", () => taskManager.GetAllPublications());
|
||||
|
||||
app.MapGet("/Tranga/GetPublicationsFromConnector", (string connectorName, string title) =>
|
||||
{
|
||||
Connector? connector = taskManager.GetAvailableConnectors().FirstOrDefault(con => con.Key == connectorName).Value;
|
||||
if (connector is null)
|
||||
@ -58,23 +76,54 @@ app.MapPost("/Tasks/Create", (string taskType, string? connectorName, string? pu
|
||||
taskManager.AddTask(task, connectorName, publication, TimeSpan.Parse(reoccurrenceTime), language??"");
|
||||
});
|
||||
|
||||
app.MapPost("/Tasks/Delete", (string taskType, string? connectorName, string? publicationId) =>
|
||||
app.MapDelete("/Tasks/Delete", (string taskType, string? connectorName, string? publicationId) =>
|
||||
{
|
||||
Publication? publication = taskManager.GetAllPublications().FirstOrDefault(pub => pub.internalId == publicationId);
|
||||
TrangaTask.Task task = Enum.Parse<TrangaTask.Task>(taskType);
|
||||
taskManager.DeleteTask(task, connectorName, publication);
|
||||
});
|
||||
|
||||
app.MapGet("/Tasks/GetList", () => taskManager.GetAllTasks());
|
||||
app.MapGet("/Tasks/Get", (string taskType, string? connectorName, string? searchString) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
TrangaTask.Task task = Enum.Parse<TrangaTask.Task>(taskType);
|
||||
if (searchString is null || connectorName is null)
|
||||
return taskManager.GetAllTasks().Where(tTask => tTask.task == task);
|
||||
else
|
||||
return taskManager.GetAllTasks().Where(tTask =>
|
||||
tTask.task == task && tTask.connectorName == connectorName && tTask.ToString()
|
||||
.Contains(searchString, StringComparison.InvariantCultureIgnoreCase));
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
return Array.Empty<TrangaTask>();
|
||||
}
|
||||
});
|
||||
|
||||
app.MapPost("/Tasks/Start", (string taskType, string? connectorName, string? publicationId) =>
|
||||
{
|
||||
TrangaTask.Task pTask = Enum.Parse<TrangaTask.Task>(taskType);
|
||||
TrangaTask? task = taskManager.GetAllTasks().FirstOrDefault(tTask =>
|
||||
tTask.task == pTask && tTask.publication?.internalId == publicationId && tTask.connectorName == connectorName);
|
||||
if (task is null)
|
||||
try
|
||||
{
|
||||
TrangaTask.Task pTask = Enum.Parse<TrangaTask.Task>(taskType);
|
||||
TrangaTask? task = null;
|
||||
if (connectorName is null || publicationId is null)
|
||||
task = taskManager.GetAllTasks().FirstOrDefault(tTask =>
|
||||
tTask.task == pTask);
|
||||
else
|
||||
task = taskManager.GetAllTasks().FirstOrDefault(tTask =>
|
||||
tTask.task == pTask && tTask.publication?.internalId == publicationId &&
|
||||
tTask.connectorName == connectorName);
|
||||
|
||||
if (task is null)
|
||||
return;
|
||||
taskManager.ExecuteTaskNow(task);
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
return;
|
||||
taskManager.ExecuteTaskNow(task);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
app.MapGet("/Tasks/GetRunningTasks",
|
||||
@ -85,38 +134,54 @@ app.MapGet("/Queue/GetList",
|
||||
|
||||
app.MapPost("/Queue/Enqueue", (string taskType, string? connectorName, string? publicationId) =>
|
||||
{
|
||||
TrangaTask.Task pTask = Enum.Parse<TrangaTask.Task>(taskType);
|
||||
TrangaTask? task = taskManager.GetAllTasks().FirstOrDefault(tTask =>
|
||||
tTask.task == pTask && tTask.publication?.internalId == publicationId && tTask.connectorName == connectorName);
|
||||
if (task is null)
|
||||
try
|
||||
{
|
||||
TrangaTask.Task pTask = Enum.Parse<TrangaTask.Task>(taskType);
|
||||
TrangaTask? task = null;
|
||||
if (connectorName is null || publicationId is null)
|
||||
task = taskManager.GetAllTasks().FirstOrDefault(tTask =>
|
||||
tTask.task == pTask);
|
||||
else
|
||||
task = taskManager.GetAllTasks().FirstOrDefault(tTask =>
|
||||
tTask.task == pTask && tTask.publication?.internalId == publicationId &&
|
||||
tTask.connectorName == connectorName);
|
||||
|
||||
if (task is null)
|
||||
return;
|
||||
taskManager.AddTaskToQueue(task);
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
return;
|
||||
taskManager.AddTaskToQueue(task);
|
||||
}
|
||||
});
|
||||
|
||||
app.MapPost("/Queue/Dequeue", (string taskType, string? connectorName, string? publicationId) =>
|
||||
app.MapDelete("/Queue/Dequeue", (string taskType, string? connectorName, string? publicationId) =>
|
||||
{
|
||||
TrangaTask.Task pTask = Enum.Parse<TrangaTask.Task>(taskType);
|
||||
TrangaTask? task = taskManager.GetAllTasks().FirstOrDefault(tTask =>
|
||||
tTask.task == pTask && tTask.publication?.internalId == publicationId && tTask.connectorName == connectorName);
|
||||
if (task is null)
|
||||
try
|
||||
{
|
||||
TrangaTask.Task pTask = Enum.Parse<TrangaTask.Task>(taskType);
|
||||
TrangaTask? task = null;
|
||||
if (connectorName is null || publicationId is null)
|
||||
task = taskManager.GetAllTasks().FirstOrDefault(tTask =>
|
||||
tTask.task == pTask);
|
||||
else
|
||||
task = taskManager.GetAllTasks().FirstOrDefault(tTask =>
|
||||
tTask.task == pTask && tTask.publication?.internalId == publicationId &&
|
||||
tTask.connectorName == connectorName);
|
||||
|
||||
if (task is null)
|
||||
return;
|
||||
taskManager.RemoveTaskFromQueue(task);
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
return;
|
||||
taskManager.RemoveTaskFromQueue(task);
|
||||
}
|
||||
});
|
||||
|
||||
app.MapGet("/Settings/Get", () => new Settings(taskManager.settings));
|
||||
app.MapGet("/Settings/Get", () => taskManager.settings);
|
||||
|
||||
app.MapPost("/Settings/Update", (string? downloadLocation, string? komgaUrl, string? komgaAuth) => taskManager.UpdateSettings(downloadLocation, komgaUrl, komgaAuth) );
|
||||
|
||||
app.Run();
|
||||
|
||||
class Settings
|
||||
{
|
||||
public string downloadLocation { get; }
|
||||
public Komga? komga { get; }
|
||||
|
||||
public Settings(TaskManager.SettingsData settings)
|
||||
{
|
||||
this.downloadLocation = settings.downloadLocation;
|
||||
this.komga = settings.komga;
|
||||
}
|
||||
}
|
||||
app.Run();
|
@ -1,18 +0,0 @@
|
||||
FROM mcr.microsoft.com/dotnet/runtime:7.0 AS base
|
||||
WORKDIR /app
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
|
||||
WORKDIR /src
|
||||
COPY ["Tranga-CLI/Tranga-CLI.csproj", "Tranga-CLI/"]
|
||||
RUN dotnet restore "Tranga-CLI/Tranga-CLI.csproj"
|
||||
COPY . .
|
||||
WORKDIR "/src/Tranga-CLI"
|
||||
RUN dotnet build "Tranga-CLI.csproj" -c Release -o /app/build
|
||||
|
||||
FROM build AS publish
|
||||
RUN dotnet publish "Tranga-CLI.csproj" -c Release -o /app/publish /p:UseAppHost=false
|
||||
|
||||
FROM base AS final
|
||||
WORKDIR /app
|
||||
COPY --from=publish /app/publish .
|
||||
ENTRYPOINT ["dotnet", "Tranga-CLI.dll"]
|
@ -14,10 +14,10 @@ public static class Tranga_Cli
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
string applicationFolderPath = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Tranga");
|
||||
string applicationFolderPath = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Tranga");
|
||||
string logsFolderPath = Path.Join(applicationFolderPath, "logs");
|
||||
string logFilePath = Path.Join(logsFolderPath, $"log-{DateTime.Now:dd-M-yyyy-HH-mm-ss}.txt");
|
||||
string settingsFilePath = Path.Join(applicationFolderPath, "data.json");
|
||||
string settingsFilePath = Path.Join(applicationFolderPath, "settings.json");
|
||||
|
||||
Directory.CreateDirectory(applicationFolderPath);
|
||||
Directory.CreateDirectory(logsFolderPath);
|
||||
@ -28,11 +28,11 @@ public static class Tranga_Cli
|
||||
Logger logger = new(new[] { Logger.LoggerType.FileLogger }, null, null, logFilePath);
|
||||
|
||||
logger.WriteLine("Tranga_CLI", "Loading Taskmanager.");
|
||||
TaskManager.SettingsData settings;
|
||||
TrangaSettings settings;
|
||||
if (File.Exists(settingsFilePath))
|
||||
settings = TaskManager.LoadData(settingsFilePath);
|
||||
settings = TrangaSettings.LoadSettings(settingsFilePath);
|
||||
else
|
||||
settings = new TaskManager.SettingsData(Directory.GetCurrentDirectory(), settingsFilePath, null, new HashSet<TrangaTask>());
|
||||
settings = new TrangaSettings(Directory.GetCurrentDirectory(), applicationFolderPath, null);
|
||||
|
||||
|
||||
logger.WriteLine("Tranga_CLI", "User Input");
|
||||
@ -40,8 +40,8 @@ public static class Tranga_Cli
|
||||
string? tmpPath = Console.ReadLine();
|
||||
while(tmpPath is null)
|
||||
tmpPath = Console.ReadLine();
|
||||
if(tmpPath.Length > 0)
|
||||
settings.UpdateSettings(pDownloadLocation: tmpPath, null);
|
||||
if (tmpPath.Length > 0)
|
||||
settings.downloadLocation = tmpPath;
|
||||
|
||||
Console.WriteLine($"Komga BaseURL [{settings.komga?.baseUrl}]:");
|
||||
string? tmpUrl = Console.ReadLine();
|
||||
@ -74,14 +74,14 @@ public static class Tranga_Cli
|
||||
}
|
||||
} 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.");
|
||||
TaskMode(settings, logger);
|
||||
}
|
||||
|
||||
private static void TaskMode(TaskManager.SettingsData settings, Logger logger)
|
||||
private static void TaskMode(TrangaSettings settings, Logger logger)
|
||||
{
|
||||
TaskManager taskManager = new (settings, logger);
|
||||
ConsoleKey selection = ConsoleKey.EraseEndOfFile;
|
||||
@ -143,7 +143,7 @@ public static class Tranga_Cli
|
||||
TailLog(logger);
|
||||
Console.ReadKey();
|
||||
break;
|
||||
case ConsoleKey.M:
|
||||
case ConsoleKey.G:
|
||||
RemoveTaskFromQueue(taskManager, logger);
|
||||
Console.WriteLine("Press any key.");
|
||||
Console.ReadKey();
|
||||
@ -153,6 +153,11 @@ public static class Tranga_Cli
|
||||
Console.WriteLine("Press any key.");
|
||||
Console.ReadKey();
|
||||
break;
|
||||
case ConsoleKey.M:
|
||||
AddMangaTaskToQueue(taskManager, logger);
|
||||
Console.WriteLine("Press any key.");
|
||||
Console.ReadKey();
|
||||
break;
|
||||
}
|
||||
PrintMenu(taskManager, taskManager.settings.downloadLocation, logger);
|
||||
}
|
||||
@ -186,8 +191,8 @@ public static class Tranga_Cli
|
||||
Console.WriteLine();
|
||||
Console.WriteLine($"{"C: Create Task",-30}{"L: List tasks",-30}{"B: Enqueue Task", -30}");
|
||||
Console.WriteLine($"{"D: Delete Task",-30}{"S: Search Tasks", -30}{"K: List Task Queue", -30}");
|
||||
Console.WriteLine($"{"E: Execute Task now",-30}{"R: List Running Tasks", -30}{"M: Remove Task from Queue", -30}");
|
||||
Console.WriteLine();
|
||||
Console.WriteLine($"{"E: Execute Task now",-30}{"R: List Running Tasks", -30}{"G: Remove Task from Queue", -30}");
|
||||
Console.WriteLine($"{"M: New Download Manga Task",-30}{"", -30}{"", -30}");
|
||||
Console.WriteLine($"{"",-30}{"F: Show Log",-30}{"Q: Exit",-30}");
|
||||
}
|
||||
|
||||
@ -204,8 +209,12 @@ public static class Tranga_Cli
|
||||
$"{"",-5}{"Task",-20} | {"Last Executed",-20} | {"Reoccurrence",-12} | {"State",-10} | {"Connector",-15} | Publication/Manga";
|
||||
Console.WriteLine(header);
|
||||
Console.WriteLine(new string('-', header.Length));
|
||||
foreach(TrangaTask trangaTask in tasks)
|
||||
Console.WriteLine($"{tIndex++:000}: {trangaTask}");
|
||||
foreach (TrangaTask trangaTask in tasks)
|
||||
{
|
||||
string[] taskSplit = trangaTask.ToString().Split(", ");
|
||||
Console.WriteLine($"{tIndex++:000}: {taskSplit[0],-20} | {taskSplit[1],-20} | {taskSplit[2],-12} | {taskSplit[3],-10} | {(taskSplit.Length > 4 ? taskSplit[4] : ""),-15} | {(taskSplit.Length > 5 ? taskSplit[5] : "")}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static TrangaTask? SelectTask(TrangaTask[] tasks, Logger logger)
|
||||
@ -239,7 +248,6 @@ public static class Tranga_Cli
|
||||
try
|
||||
{
|
||||
int selectedTaskIndex = Convert.ToInt32(selectedTask);
|
||||
logger.WriteLine("Tranga_CLI", "Sending Task to TaskManager");
|
||||
return tasks[selectedTaskIndex];
|
||||
}
|
||||
catch (Exception e)
|
||||
@ -250,6 +258,25 @@ public static class Tranga_Cli
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void AddMangaTaskToQueue(TaskManager taskManager, Logger logger)
|
||||
{
|
||||
Console.Clear();
|
||||
logger.WriteLine("Tranga_CLI", "Menu: Add Manga Download to queue");
|
||||
|
||||
Connector? connector = SelectConnector(taskManager.settings.downloadLocation, taskManager.GetAvailableConnectors().Values.ToArray(), logger);
|
||||
if (connector is null)
|
||||
return;
|
||||
|
||||
Publication? publication = SelectPublication(taskManager, connector!, logger);
|
||||
if (publication is null)
|
||||
return;
|
||||
|
||||
TimeSpan reoccurrence = SelectReoccurrence(logger);
|
||||
logger.WriteLine("Tranga_CLI", "Sending Task to TaskManager");
|
||||
TrangaTask newTask = taskManager.AddTask(TrangaTask.Task.DownloadNewChapters, connector?.name, publication, reoccurrence, "en");
|
||||
Console.WriteLine(newTask);
|
||||
}
|
||||
|
||||
private static void AddTaskToQueue(TaskManager taskManager, Logger logger)
|
||||
{
|
||||
@ -300,7 +327,7 @@ public static class Tranga_Cli
|
||||
}
|
||||
}
|
||||
|
||||
private static void CreateTask(TaskManager taskManager, TaskManager.SettingsData settings, Logger logger)
|
||||
private static void CreateTask(TaskManager taskManager, TrangaSettings settings, Logger logger)
|
||||
{
|
||||
logger.WriteLine("Tranga_CLI", "Menu: Creating Task");
|
||||
TrangaTask.Task? tmpTask = SelectTaskType(logger);
|
||||
@ -319,7 +346,7 @@ public static class Tranga_Cli
|
||||
Publication? publication = null;
|
||||
if (task != TrangaTask.Task.UpdatePublications && task != TrangaTask.Task.UpdateKomgaLibrary)
|
||||
{
|
||||
publication = SelectPublication(connector!, logger);
|
||||
publication = SelectPublication(taskManager, connector!, logger);
|
||||
if (publication is null)
|
||||
return;
|
||||
}
|
||||
@ -443,7 +470,7 @@ public static class Tranga_Cli
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Publication? SelectPublication(Connector connector, Logger logger)
|
||||
private static Publication? SelectPublication(TaskManager taskManager, Connector connector, Logger logger)
|
||||
{
|
||||
logger.WriteLine("Tranga_CLI", "Menu: Select Publication");
|
||||
|
||||
@ -452,7 +479,14 @@ public static class Tranga_Cli
|
||||
Console.WriteLine("Publication search query (leave empty for all):");
|
||||
string? query = Console.ReadLine();
|
||||
|
||||
Publication[] publications = connector.GetPublications(query ?? "");
|
||||
Publication[] publications = taskManager.GetPublicationsFromConnector(connector, query ?? "");
|
||||
|
||||
if (publications.Length < 1)
|
||||
{
|
||||
logger.WriteLine("Tranga_CLI", "No publications returned");
|
||||
Console.WriteLine($"No publications for query '{query}' returned;");
|
||||
return null;
|
||||
}
|
||||
|
||||
int pIndex = 0;
|
||||
Console.WriteLine("Publications:");
|
||||
|
@ -12,15 +12,18 @@ namespace Tranga;
|
||||
public abstract class Connector
|
||||
{
|
||||
internal string downloadLocation { get; } //Location of local files
|
||||
protected DownloadClient downloadClient { get; }
|
||||
protected DownloadClient downloadClient { get; init; }
|
||||
|
||||
protected Logger? logger;
|
||||
|
||||
protected Connector(string downloadLocation, uint downloadDelay, Logger? logger)
|
||||
protected Connector(string downloadLocation, Logger? logger)
|
||||
{
|
||||
this.downloadLocation = downloadLocation;
|
||||
this.downloadClient = new DownloadClient(downloadDelay);
|
||||
this.logger = logger;
|
||||
this.downloadClient = new DownloadClient(new Dictionary<byte, int>()
|
||||
{
|
||||
//RequestTypes for RateLimits
|
||||
}, logger);
|
||||
}
|
||||
|
||||
public abstract string name { get; } //Name of the Connector (e.g. Website)
|
||||
@ -85,6 +88,7 @@ public abstract class Connector
|
||||
new XElement("Tags", string.Join(',',publication.tags)),
|
||||
new XElement("LanguageISO", publication.originalLanguage),
|
||||
new XElement("Title", chapter.name),
|
||||
new XElement("Writer", publication.author),
|
||||
new XElement("Volume", chapter.volumeNumber),
|
||||
new XElement("Number", chapter.chapterNumber) //TODO check if this is correct at some point
|
||||
);
|
||||
@ -106,23 +110,24 @@ public abstract class Connector
|
||||
/// <returns>Filepath</returns>
|
||||
protected string CreateFullFilepath(Publication publication, Chapter chapter)
|
||||
{
|
||||
return Path.Join(downloadLocation, publication.folderName, chapter.fileName);
|
||||
return Path.Join(downloadLocation, publication.folderName, $"{chapter.fileName}.cbz");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Downloads Image from URL and saves it to the given path(incl. fileName)
|
||||
/// </summary>
|
||||
/// <param name="imageUrl"></param>
|
||||
/// <param name="fullPath"></param>
|
||||
/// <param name="downloadClient">DownloadClient of the connector</param>
|
||||
protected static void DownloadImage(string imageUrl, string fullPath, DownloadClient downloadClient)
|
||||
/// <param name="requestType">Requesttype for ratelimit</param>
|
||||
protected static void DownloadImage(string imageUrl, string fullPath, DownloadClient downloadClient, byte requestType)
|
||||
{
|
||||
DownloadClient.RequestResult requestResult = downloadClient.MakeRequest(imageUrl);
|
||||
DownloadClient.RequestResult requestResult = downloadClient.MakeRequest(imageUrl, requestType);
|
||||
byte[] buffer = new byte[requestResult.result.Length];
|
||||
requestResult.result.ReadExactly(buffer, 0, buffer.Length);
|
||||
File.WriteAllBytes(fullPath, buffer);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Downloads all Images from URLs, Compresses to zip(cbz) and saves.
|
||||
/// </summary>
|
||||
@ -130,17 +135,16 @@ public abstract class Connector
|
||||
/// <param name="saveArchiveFilePath">Full path to save archive to (without file ending .cbz)</param>
|
||||
/// <param name="downloadClient">DownloadClient of the connector</param>
|
||||
/// <param name="comicInfoPath">Path of the generate Chapter ComicInfo.xml, if it was generated</param>
|
||||
protected static void DownloadChapterImages(string[] imageUrls, string saveArchiveFilePath, DownloadClient downloadClient, Logger? logger, string? comicInfoPath = null)
|
||||
/// <param name="requestType">RequestType for RateLimits</param>
|
||||
protected static void DownloadChapterImages(string[] imageUrls, string saveArchiveFilePath, DownloadClient downloadClient, byte requestType, Logger? logger, string? comicInfoPath = null)
|
||||
{
|
||||
logger?.WriteLine("Connector", "Downloading Images");
|
||||
//Check if Publication Directory already exists
|
||||
string[] splitPath = saveArchiveFilePath.Split(Path.DirectorySeparatorChar);
|
||||
string directoryPath = Path.Combine(splitPath.Take(splitPath.Length - 1).ToArray());
|
||||
string directoryPath = Path.GetDirectoryName(saveArchiveFilePath)!;
|
||||
if (!Directory.Exists(directoryPath))
|
||||
Directory.CreateDirectory(directoryPath);
|
||||
|
||||
string fullPath = $"{saveArchiveFilePath}.cbz";
|
||||
if (File.Exists(fullPath)) //Don't download twice.
|
||||
|
||||
if (File.Exists(saveArchiveFilePath)) //Don't download twice.
|
||||
return;
|
||||
|
||||
//Create a temporary folder to store images
|
||||
@ -152,7 +156,7 @@ public abstract class Connector
|
||||
{
|
||||
string[] split = imageUrl.Split('.');
|
||||
string extension = split[^1];
|
||||
DownloadImage(imageUrl, Path.Join(tempFolder, $"{chapter++}.{extension}"), downloadClient);
|
||||
DownloadImage(imageUrl, Path.Join(tempFolder, $"{chapter++}.{extension}"), downloadClient, requestType);
|
||||
}
|
||||
|
||||
if(comicInfoPath is not null)
|
||||
@ -160,40 +164,72 @@ public abstract class Connector
|
||||
|
||||
logger?.WriteLine("Connector", "Creating archive");
|
||||
//ZIP-it and ship-it
|
||||
ZipFile.CreateFromDirectory(tempFolder, fullPath);
|
||||
ZipFile.CreateFromDirectory(tempFolder, saveArchiveFilePath);
|
||||
Directory.Delete(tempFolder, true); //Cleanup
|
||||
}
|
||||
|
||||
protected class DownloadClient
|
||||
{
|
||||
private readonly TimeSpan _requestSpeed;
|
||||
private DateTime _lastRequest;
|
||||
private static readonly HttpClient Client = new();
|
||||
|
||||
private readonly Dictionary<byte, DateTime> _lastExecutedRateLimit;
|
||||
private readonly Dictionary<byte, TimeSpan> _rateLimit;
|
||||
private Logger? logger;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a httpClient
|
||||
/// </summary>
|
||||
/// <param name="delay">minimum delay between requests (to avoid spam)</param>
|
||||
public DownloadClient(uint delay)
|
||||
/// <param name="rateLimitRequestsPerMinute">Rate limits for requests. byte is RequestType, int maximum requests per minute for RequestType</param>
|
||||
public DownloadClient(Dictionary<byte, int> rateLimitRequestsPerMinute, Logger? logger)
|
||||
{
|
||||
_requestSpeed = TimeSpan.FromMilliseconds(delay);
|
||||
_lastRequest = DateTime.Now.Subtract(_requestSpeed);
|
||||
this.logger = logger;
|
||||
_lastExecutedRateLimit = new();
|
||||
_rateLimit = new();
|
||||
foreach(KeyValuePair<byte, int> limit in rateLimitRequestsPerMinute)
|
||||
_rateLimit.Add(limit.Key, TimeSpan.FromMinutes(1).Divide(limit.Value));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Request Webpage
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="requestType">For RateLimits: Same Endpoints use same type</param>
|
||||
/// <returns>RequestResult with StatusCode and Stream of received data</returns>
|
||||
public RequestResult MakeRequest(string url)
|
||||
public RequestResult MakeRequest(string url, byte requestType)
|
||||
{
|
||||
while((DateTime.Now - _lastRequest) < _requestSpeed)
|
||||
Thread.Sleep(10);
|
||||
_lastRequest = DateTime.Now;
|
||||
if (_rateLimit.TryGetValue(requestType, out TimeSpan value))
|
||||
_lastExecutedRateLimit.TryAdd(requestType, DateTime.Now.Subtract(value));
|
||||
else
|
||||
{
|
||||
logger?.WriteLine(this.GetType().ToString(), "RequestType not configured for rate-limit.");
|
||||
return new RequestResult(HttpStatusCode.NotAcceptable, Stream.Null);
|
||||
}
|
||||
|
||||
HttpRequestMessage requestMessage = new(HttpMethod.Get, url);
|
||||
HttpResponseMessage response = Client.Send(requestMessage);
|
||||
TimeSpan rateLimitTimeout = _rateLimit[requestType]
|
||||
.Subtract(DateTime.Now.Subtract(_lastExecutedRateLimit[requestType]));
|
||||
|
||||
if(rateLimitTimeout > TimeSpan.Zero)
|
||||
Thread.Sleep(rateLimitTimeout);
|
||||
|
||||
HttpResponseMessage? response = null;
|
||||
while (response is null)
|
||||
{
|
||||
try
|
||||
{
|
||||
HttpRequestMessage requestMessage = new(HttpMethod.Get, url);
|
||||
_lastExecutedRateLimit[requestType] = DateTime.Now;
|
||||
response = Client.Send(requestMessage);
|
||||
}
|
||||
catch (HttpRequestException e)
|
||||
{
|
||||
logger?.WriteLine(this.GetType().ToString(), e.Message);
|
||||
Thread.Sleep(_rateLimit[requestType] * 2);
|
||||
}
|
||||
}
|
||||
Stream resultString = response.IsSuccessStatusCode ? response.Content.ReadAsStream() : Stream.Null;
|
||||
if (!response.IsSuccessStatusCode)
|
||||
logger?.WriteLine(this.GetType().ToString(), $"Request-Error {response.StatusCode}: {response.ReasonPhrase}");
|
||||
return new RequestResult(response.StatusCode, resultString);
|
||||
}
|
||||
|
||||
|
@ -9,14 +9,26 @@ public class MangaDex : Connector
|
||||
{
|
||||
public override string name { get; }
|
||||
|
||||
public MangaDex(string downloadLocation, uint downloadDelay, Logger? logger) : base(downloadLocation, downloadDelay, logger)
|
||||
private enum RequestType : byte
|
||||
{
|
||||
name = "MangaDex";
|
||||
Manga,
|
||||
Feed,
|
||||
AtHomeServer,
|
||||
Cover,
|
||||
Author
|
||||
}
|
||||
|
||||
public MangaDex(string downloadLocation, Logger? logger) : base(downloadLocation, 750, logger)
|
||||
|
||||
public MangaDex(string downloadLocation, Logger? logger) : base(downloadLocation, logger)
|
||||
{
|
||||
name = "MangaDex";
|
||||
this.downloadClient = new DownloadClient(new Dictionary<byte, int>()
|
||||
{
|
||||
{(byte)RequestType.Manga, 250},
|
||||
{(byte)RequestType.Feed, 250},
|
||||
{(byte)RequestType.AtHomeServer, 40},
|
||||
{(byte)RequestType.Cover, 250},
|
||||
{(byte)RequestType.Author, 250}
|
||||
}, logger);
|
||||
}
|
||||
|
||||
public override Publication[] GetPublications(string publicationTitle = "")
|
||||
@ -31,7 +43,7 @@ public class MangaDex : Connector
|
||||
//Request next Page
|
||||
DownloadClient.RequestResult requestResult =
|
||||
downloadClient.MakeRequest(
|
||||
$"https://api.mangadex.org/manga?limit={limit}&title={publicationTitle}&offset={offset}");
|
||||
$"https://api.mangadex.org/manga?limit={limit}&title={publicationTitle}&offset={offset}", (byte)RequestType.Manga);
|
||||
if (requestResult.statusCode != HttpStatusCode.OK)
|
||||
break;
|
||||
JsonObject? result = JsonSerializer.Deserialize<JsonObject>(requestResult.result);
|
||||
@ -49,6 +61,8 @@ public class MangaDex : Connector
|
||||
JsonObject manga = (JsonObject)mangeNode!;
|
||||
JsonObject attributes = manga["attributes"]!.AsObject();
|
||||
|
||||
string publicationId = manga["id"]!.GetValue<string>();
|
||||
|
||||
string title = attributes["title"]!.AsObject().ContainsKey("en") && attributes["title"]!["en"] is not null
|
||||
? attributes["title"]!["en"]!.GetValue<string>()
|
||||
: attributes["title"]![((IDictionary<string, JsonNode?>)attributes["title"]!.AsObject()).Keys.First()]!.GetValue<string>();
|
||||
@ -75,15 +89,18 @@ public class MangaDex : Connector
|
||||
tags.Add(tagObject["attributes"]!["name"]!["en"]!.GetValue<string>());
|
||||
}
|
||||
|
||||
string? poster = null;
|
||||
string? posterId = null;
|
||||
string? authorId = null;
|
||||
if (manga.ContainsKey("relationships") && manga["relationships"] is not null)
|
||||
{
|
||||
JsonArray relationships = manga["relationships"]!.AsArray();
|
||||
poster = relationships.FirstOrDefault(relationship => relationship!["type"]!.GetValue<string>() == "cover_art")!["id"]!.GetValue<string>();
|
||||
posterId = relationships.FirstOrDefault(relationship => relationship!["type"]!.GetValue<string>() == "cover_art")!["id"]!.GetValue<string>();
|
||||
authorId = relationships.FirstOrDefault(relationship => relationship!["type"]!.GetValue<string>() == "author")!["id"]!.GetValue<string>();
|
||||
}
|
||||
string? coverUrl = GetCoverUrl(publicationId, posterId);
|
||||
string? author = GetAuthor(authorId);
|
||||
|
||||
Dictionary<string, string> linksDict = new();
|
||||
string[,]? links = null;
|
||||
if (attributes.ContainsKey("links") && attributes["links"] is not null)
|
||||
{
|
||||
JsonObject linksObject = attributes["links"]!.AsObject();
|
||||
@ -103,17 +120,18 @@ public class MangaDex : Connector
|
||||
|
||||
string status = attributes["status"]!.GetValue<string>();
|
||||
|
||||
Publication pub = new Publication(
|
||||
Publication pub = new (
|
||||
title,
|
||||
author,
|
||||
description,
|
||||
altTitlesDict,
|
||||
tags.ToArray(),
|
||||
poster,
|
||||
coverUrl,
|
||||
linksDict,
|
||||
year,
|
||||
originalLanguage,
|
||||
status,
|
||||
manga["id"]!.GetValue<string>()
|
||||
publicationId
|
||||
);
|
||||
publications.Add(pub); //Add Publication (Manga) to result
|
||||
}
|
||||
@ -135,7 +153,7 @@ public class MangaDex : Connector
|
||||
//Request next "Page"
|
||||
DownloadClient.RequestResult requestResult =
|
||||
downloadClient.MakeRequest(
|
||||
$"https://api.mangadex.org/manga/{publication.downloadUrl}/feed?limit={limit}&offset={offset}&translatedLanguage%5B%5D={language}");
|
||||
$"https://api.mangadex.org/manga/{publication.publicationId}/feed?limit={limit}&offset={offset}&translatedLanguage%5B%5D={language}", (byte)RequestType.Feed);
|
||||
if (requestResult.statusCode != HttpStatusCode.OK)
|
||||
break;
|
||||
JsonObject? result = JsonSerializer.Deserialize<JsonObject>(requestResult.result);
|
||||
@ -182,7 +200,7 @@ public class MangaDex : Connector
|
||||
logger?.WriteLine(this.GetType().ToString(), $"Download Chapter {publication.sortName} {chapter.volumeNumber}-{chapter.chapterNumber}");
|
||||
//Request URLs for Chapter-Images
|
||||
DownloadClient.RequestResult requestResult =
|
||||
downloadClient.MakeRequest($"https://api.mangadex.org/at-home/server/{chapter.url}?forcePort443=false'");
|
||||
downloadClient.MakeRequest($"https://api.mangadex.org/at-home/server/{chapter.url}?forcePort443=false'", (byte)RequestType.AtHomeServer);
|
||||
if (requestResult.statusCode != HttpStatusCode.OK)
|
||||
return;
|
||||
JsonObject? result = JsonSerializer.Deserialize<JsonObject>(requestResult.result);
|
||||
@ -201,7 +219,47 @@ public class MangaDex : Connector
|
||||
File.WriteAllText(comicInfoPath, CreateComicInfo(publication, chapter, logger));
|
||||
|
||||
//Download Chapter-Images
|
||||
DownloadChapterImages(imageUrls.ToArray(), CreateFullFilepath(publication, chapter), downloadClient, logger, comicInfoPath);
|
||||
DownloadChapterImages(imageUrls.ToArray(), CreateFullFilepath(publication, chapter), downloadClient, (byte)RequestType.AtHomeServer, logger, comicInfoPath);
|
||||
}
|
||||
|
||||
private string? GetCoverUrl(string publicationId, string? posterId)
|
||||
{
|
||||
if (posterId is null)
|
||||
{
|
||||
logger?.WriteLine(this.GetType().ToString(), $"No posterId");
|
||||
return null;
|
||||
}
|
||||
|
||||
//Request information where to download Cover
|
||||
DownloadClient.RequestResult requestResult =
|
||||
downloadClient.MakeRequest($"https://api.mangadex.org/cover/{posterId}", (byte)RequestType.Cover);
|
||||
if (requestResult.statusCode != HttpStatusCode.OK)
|
||||
return null;
|
||||
JsonObject? result = JsonSerializer.Deserialize<JsonObject>(requestResult.result);
|
||||
if (result is null)
|
||||
return null;
|
||||
|
||||
string fileName = result["data"]!["attributes"]!["fileName"]!.GetValue<string>();
|
||||
|
||||
string coverUrl = $"https://uploads.mangadex.org/covers/{publicationId}/{fileName}";
|
||||
return coverUrl;
|
||||
}
|
||||
|
||||
private string? GetAuthor(string? authorId)
|
||||
{
|
||||
if (authorId is null)
|
||||
return null;
|
||||
|
||||
DownloadClient.RequestResult requestResult =
|
||||
downloadClient.MakeRequest($"https://api.mangadex.org/author/{authorId}", (byte)RequestType.Author);
|
||||
if (requestResult.statusCode != HttpStatusCode.OK)
|
||||
return null;
|
||||
JsonObject? result = JsonSerializer.Deserialize<JsonObject>(requestResult.result);
|
||||
if (result is null)
|
||||
return null;
|
||||
|
||||
string author = result["data"]!["attributes"]!["name"]!.GetValue<string>();
|
||||
return author;
|
||||
}
|
||||
|
||||
public override void DownloadCover(Publication publication)
|
||||
@ -212,31 +270,26 @@ public class MangaDex : Connector
|
||||
if(!Directory.Exists(publicationFolder))
|
||||
Directory.CreateDirectory(publicationFolder);
|
||||
DirectoryInfo dirInfo = new (publicationFolder);
|
||||
foreach(FileInfo fileInfo in dirInfo.EnumerateFiles())
|
||||
if (fileInfo.Name.Contains("cover."))
|
||||
return;
|
||||
|
||||
//Request information where to download Cover
|
||||
DownloadClient.RequestResult requestResult =
|
||||
downloadClient.MakeRequest($"https://api.mangadex.org/cover/{publication.posterUrl}");
|
||||
if (requestResult.statusCode != HttpStatusCode.OK)
|
||||
if (dirInfo.EnumerateFiles().Any(info => info.Name.Contains("cover.")))
|
||||
{
|
||||
logger?.WriteLine(this.GetType().ToString(), $"Cover exists {publication.sortName}");
|
||||
return;
|
||||
JsonObject? result = JsonSerializer.Deserialize<JsonObject>(requestResult.result);
|
||||
if (result is null)
|
||||
}
|
||||
|
||||
if (publication.posterUrl is null || publication.posterUrl!.Contains("http"))
|
||||
{
|
||||
logger?.WriteLine(this.GetType().ToString(), $"No Poster-URL in publication");
|
||||
return;
|
||||
}
|
||||
|
||||
string fileName = result["data"]!["attributes"]!["fileName"]!.GetValue<string>();
|
||||
|
||||
string coverUrl = $"https://uploads.mangadex.org/covers/{publication.downloadUrl}/{fileName}";
|
||||
|
||||
//Get file-extension (jpg, png)
|
||||
string[] split = coverUrl.Split('.');
|
||||
string[] split = publication.posterUrl.Split('.');
|
||||
string extension = split[^1];
|
||||
|
||||
string outFolderPath = Path.Join(downloadLocation, publication.folderName);
|
||||
Directory.CreateDirectory(outFolderPath);
|
||||
|
||||
//Download cover-Image
|
||||
DownloadImage(coverUrl, Path.Join(downloadLocation, publication.folderName, $"cover.{extension}"), this.downloadClient);
|
||||
DownloadImage(publication.posterUrl, Path.Join(downloadLocation, publication.folderName, $"cover.{extension}"), this.downloadClient, (byte)RequestType.AtHomeServer);
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
using System.Net.Http.Headers;
|
||||
using System.Net;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text.Json.Nodes;
|
||||
using Logging;
|
||||
using Newtonsoft.Json;
|
||||
@ -45,9 +46,17 @@ public class Komga
|
||||
{
|
||||
logger?.WriteLine(this.GetType().ToString(), $"Getting Libraries");
|
||||
Stream data = NetClient.MakeRequest($"{baseUrl}/api/v1/libraries", auth);
|
||||
if (data == Stream.Null)
|
||||
{
|
||||
logger?.WriteLine(this.GetType().ToString(), $"No libraries returned");
|
||||
return Array.Empty<KomgaLibrary>();
|
||||
}
|
||||
JsonArray? result = JsonSerializer.Deserialize<JsonArray>(data);
|
||||
if (result is null)
|
||||
{
|
||||
logger?.WriteLine(this.GetType().ToString(), $"No libraries returned");
|
||||
return Array.Empty<KomgaLibrary>();
|
||||
}
|
||||
|
||||
HashSet<KomgaLibrary> ret = new();
|
||||
|
||||
@ -89,37 +98,51 @@ public class Komga
|
||||
{
|
||||
public static Stream MakeRequest(string url, string auth)
|
||||
{
|
||||
HttpClient client = new();
|
||||
HttpRequestMessage requestMessage = new HttpRequestMessage
|
||||
HttpClientHandler clientHandler = new ();
|
||||
clientHandler.ServerCertificateCustomValidationCallback = (message, cert, chain, sslPolicyErrors) => true;
|
||||
HttpClient client = new(clientHandler);
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", auth);
|
||||
|
||||
HttpRequestMessage requestMessage = new ()
|
||||
{
|
||||
Method = HttpMethod.Get,
|
||||
RequestUri = new Uri(url),
|
||||
Headers =
|
||||
{
|
||||
{ "Accept", "application/json" },
|
||||
{ "Authorization", new AuthenticationHeaderValue("Basic", auth).ToString() }
|
||||
}
|
||||
RequestUri = new Uri(url)
|
||||
};
|
||||
HttpResponseMessage response = client.Send(requestMessage);
|
||||
Stream resultString = response.IsSuccessStatusCode ? response.Content.ReadAsStream() : Stream.Null;
|
||||
return resultString;
|
||||
Stream ret;
|
||||
if (response.StatusCode is HttpStatusCode.Unauthorized)
|
||||
{
|
||||
ret = MakeRequest(response.RequestMessage!.RequestUri!.AbsoluteUri, auth);
|
||||
}else
|
||||
return response.IsSuccessStatusCode ? response.Content.ReadAsStream() : Stream.Null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static bool MakePost(string url, string auth)
|
||||
{
|
||||
HttpClient client = new();
|
||||
HttpRequestMessage requestMessage = new HttpRequestMessage
|
||||
HttpClientHandler clientHandler = new HttpClientHandler();
|
||||
clientHandler.ServerCertificateCustomValidationCallback = (message, cert, chain, sslPolicyErrors) => true;
|
||||
HttpClient client = new(clientHandler)
|
||||
{
|
||||
Method = HttpMethod.Post,
|
||||
RequestUri = new Uri(url),
|
||||
Headers =
|
||||
DefaultRequestHeaders =
|
||||
{
|
||||
{ "Accept", "application/json" },
|
||||
{ "Authorization", new AuthenticationHeaderValue("Basic", auth).ToString() }
|
||||
}
|
||||
};
|
||||
HttpRequestMessage requestMessage = new HttpRequestMessage
|
||||
{
|
||||
Method = HttpMethod.Post,
|
||||
RequestUri = new Uri(url)
|
||||
};
|
||||
HttpResponseMessage response = client.Send(requestMessage);
|
||||
return response.IsSuccessStatusCode;
|
||||
bool ret;
|
||||
if (response.StatusCode is HttpStatusCode.Unauthorized)
|
||||
{
|
||||
ret = MakePost(response.RequestMessage!.RequestUri!.AbsoluteUri, auth);
|
||||
}else
|
||||
return response.IsSuccessStatusCode;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Tranga;
|
||||
|
||||
@ -8,28 +9,24 @@ namespace Tranga;
|
||||
public readonly struct Publication
|
||||
{
|
||||
public string sortName { get; }
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global we need it, trust
|
||||
[JsonIgnore]public Dictionary<string,string> altTitles { get; }
|
||||
public string? author { get; }
|
||||
public Dictionary<string,string> altTitles { get; }
|
||||
// ReSharper disable trice MemberCanBePrivate.Global, trust
|
||||
public string? description { get; }
|
||||
public string[] tags { get; }
|
||||
public string? posterUrl { get; }
|
||||
[JsonIgnore]public Dictionary<string,string> links { get; }
|
||||
public Dictionary<string,string> links { get; }
|
||||
public int? year { get; }
|
||||
public string? originalLanguage { get; }
|
||||
public string status { get; }
|
||||
public string folderName { get; }
|
||||
public string downloadUrl { get; }
|
||||
public string publicationId { get; }
|
||||
public string internalId { get; }
|
||||
|
||||
public readonly struct ValueTuple
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Publication(string sortName, string? description, Dictionary<string,string> altTitles, string[] tags, string? posterUrl, Dictionary<string,string>? links, int? year, string? originalLanguage, string status, string downloadUrl)
|
||||
public Publication(string sortName, string? author, string? description, Dictionary<string,string> altTitles, string[] tags, string? posterUrl, Dictionary<string,string>? links, int? year, string? originalLanguage, string status, string publicationId)
|
||||
{
|
||||
this.sortName = sortName;
|
||||
this.author = author;
|
||||
this.description = description;
|
||||
this.altTitles = altTitles;
|
||||
this.tags = tags;
|
||||
@ -38,9 +35,10 @@ public readonly struct Publication
|
||||
this.year = year;
|
||||
this.originalLanguage = originalLanguage;
|
||||
this.status = status;
|
||||
this.downloadUrl = downloadUrl;
|
||||
this.publicationId = publicationId;
|
||||
this.folderName = string.Concat(sortName.Split(Path.GetInvalidPathChars().Concat(Path.GetInvalidFileNameChars()).ToArray()));
|
||||
this.internalId = Guid.NewGuid().ToString();
|
||||
string onlyLowerLetters = string.Concat(this.sortName.ToLower().Where(Char.IsLetter));
|
||||
this.internalId = Convert.ToBase64String(Encoding.ASCII.GetBytes($"{onlyLowerLetters}{this.year}"));
|
||||
}
|
||||
|
||||
/// <returns>Serialized JSON String for series.json</returns>
|
||||
|
@ -92,13 +92,13 @@ public static class TaskExecutor
|
||||
/// <param name="chapterCollection"></param>
|
||||
private static void DownloadNewChapters(Connector connector, Publication publication, string language, ref Dictionary<Publication, List<Chapter>> chapterCollection)
|
||||
{
|
||||
List<Chapter> newChapters = UpdateChapters(connector, publication, language, ref chapterCollection);
|
||||
connector.DownloadCover(publication);
|
||||
|
||||
//Check if Publication already has a Folder and a series.json
|
||||
//Check if Publication already has a Folder
|
||||
string publicationFolder = Path.Join(connector.downloadLocation, publication.folderName);
|
||||
if(!Directory.Exists(publicationFolder))
|
||||
Directory.CreateDirectory(publicationFolder);
|
||||
List<Chapter> newChapters = UpdateChapters(connector, publication, language, ref chapterCollection);
|
||||
|
||||
connector.DownloadCover(publication);
|
||||
|
||||
string seriesInfoPath = Path.Join(publicationFolder, "series.json");
|
||||
if(!File.Exists(seriesInfoPath))
|
||||
|
@ -11,28 +11,30 @@ namespace Tranga;
|
||||
public class TaskManager
|
||||
{
|
||||
public Dictionary<Publication, List<Chapter>> _chapterCollection = new();
|
||||
private readonly HashSet<TrangaTask> _allTasks;
|
||||
private HashSet<TrangaTask> _allTasks;
|
||||
private bool _continueRunning = true;
|
||||
private readonly Connector[] _connectors;
|
||||
private readonly Dictionary<Connector, List<TrangaTask>> _taskQueue = new();
|
||||
public SettingsData settings { get; }
|
||||
public TrangaSettings settings { get; }
|
||||
private Logger? logger { get; }
|
||||
public Komga? komga { get; }
|
||||
public Komga? komga => settings.komga;
|
||||
|
||||
/// <param name="downloadFolderPath">Local path to save data (Manga) to</param>
|
||||
/// <param name="settingsFilePath">Path to the settings file (data.json)</param>
|
||||
/// <param name="workingDirectory">Path to the working directory</param>
|
||||
/// <param name="komgaBaseUrl">The Url of the Komga-instance that you want to update</param>
|
||||
/// <param name="komgaUsername">The Komga username</param>
|
||||
/// <param name="komgaPassword">The Komga password</param>
|
||||
/// <param name="logger"></param>
|
||||
public TaskManager(string downloadFolderPath, string? settingsFilePath = null, string? komgaBaseUrl = null, string? komgaUsername = null, string? komgaPassword = null, Logger? logger = null)
|
||||
public TaskManager(string downloadFolderPath, string workingDirectory, string? komgaBaseUrl = null, string? komgaUsername = null, string? komgaPassword = null, Logger? logger = null)
|
||||
{
|
||||
this.logger = logger;
|
||||
_allTasks = new HashSet<TrangaTask>();
|
||||
|
||||
Komga? newKomga = null;
|
||||
if (komgaBaseUrl != null && komgaUsername != null && komgaPassword != null)
|
||||
this.komga = new Komga(komgaBaseUrl, komgaUsername, komgaPassword, logger);
|
||||
newKomga = new Komga(komgaBaseUrl, komgaUsername, komgaPassword, logger);
|
||||
|
||||
this.settings = new SettingsData(downloadFolderPath, settingsFilePath, this.komga, this._allTasks);
|
||||
this.settings = new TrangaSettings(downloadFolderPath, workingDirectory, newKomga);
|
||||
ExportData();
|
||||
|
||||
this._connectors = new Connector[]{ new MangaDex(downloadFolderPath, logger) };
|
||||
@ -48,21 +50,22 @@ public class TaskManager
|
||||
Komga? komga = null;
|
||||
if (komgaUrl is not null && komgaAuth is not null)
|
||||
komga = new Komga(komgaUrl, komgaAuth, null);
|
||||
settings.UpdateSettings(downloadLocation, komga);
|
||||
settings.downloadLocation = downloadLocation ?? settings.downloadLocation;
|
||||
settings.komga = komga ?? komga;
|
||||
ExportData();
|
||||
}
|
||||
|
||||
public TaskManager(SettingsData settings, Logger? logger = null)
|
||||
public TaskManager(TrangaSettings settings, Logger? logger = null)
|
||||
{
|
||||
this.logger = logger;
|
||||
this._connectors = new Connector[]{ new MangaDex(settings.downloadLocation, logger) };
|
||||
this.settings = settings;
|
||||
ExportData();
|
||||
|
||||
foreach(Connector cConnector in this._connectors)
|
||||
_taskQueue.Add(cConnector, new List<TrangaTask>());
|
||||
this.komga = settings.komga;
|
||||
_allTasks = settings.allTasks;
|
||||
_allTasks = new HashSet<TrangaTask>();
|
||||
|
||||
this.settings = settings;
|
||||
ImportData();
|
||||
ExportData();
|
||||
Thread taskChecker = new(TaskCheckerThread);
|
||||
taskChecker.Start();
|
||||
}
|
||||
@ -160,12 +163,14 @@ public class TaskManager
|
||||
|
||||
//Check if same task already exists
|
||||
if (!_allTasks.Any(trangaTask => trangaTask.task == task && trangaTask.connectorName == connector.name &&
|
||||
trangaTask.publication?.downloadUrl == publication?.downloadUrl))
|
||||
trangaTask.publication?.internalId == publication?.internalId))
|
||||
{
|
||||
if(task != TrangaTask.Task.UpdatePublications)
|
||||
_chapterCollection.TryAdd((Publication)publication!, new List<Chapter>());
|
||||
_allTasks.Add(newTask);
|
||||
}
|
||||
else
|
||||
logger?.WriteLine(this.GetType().ToString(), $"Publication already exists {publication?.internalId}");
|
||||
}
|
||||
logger?.WriteLine(this.GetType().ToString(), $"Added new Task {newTask.ToString()}");
|
||||
ExportData();
|
||||
@ -185,18 +190,25 @@ public class TaskManager
|
||||
if (task == TrangaTask.Task.UpdateKomgaLibrary)
|
||||
{
|
||||
_allTasks.RemoveWhere(uTask => uTask.task == TrangaTask.Task.UpdateKomgaLibrary);
|
||||
logger?.WriteLine(this.GetType().ToString(), $"Removed Task {task}");
|
||||
logger?.WriteLine(this.GetType().ToString(), $"Removed Task {task} from all Tasks.");
|
||||
}
|
||||
else if (connectorName is null)
|
||||
throw new ArgumentException($"connectorName can not be null for Task {task}");
|
||||
else
|
||||
{
|
||||
foreach (List<TrangaTask> taskQueue in this._taskQueue.Values)
|
||||
if(taskQueue.RemoveAll(trangaTask =>
|
||||
trangaTask.task == task && trangaTask.connectorName == connectorName &&
|
||||
trangaTask.publication?.internalId == publication?.internalId) > 0)
|
||||
logger?.WriteLine(this.GetType().ToString(), $"Removed Task {task} {publication?.sortName} {publication?.internalId} from Queue.");
|
||||
else
|
||||
logger?.WriteLine(this.GetType().ToString(), $"Task {task} {publication?.sortName} {publication?.internalId} was not in Queue.");
|
||||
if(_allTasks.RemoveWhere(trangaTask =>
|
||||
trangaTask.task == task && trangaTask.connectorName == connectorName &&
|
||||
trangaTask.publication?.downloadUrl == publication?.downloadUrl) > 0)
|
||||
logger?.WriteLine(this.GetType().ToString(), $"Removed Task {task} {publication?.sortName} {publication?.downloadUrl}.");
|
||||
trangaTask.publication?.internalId == publication?.internalId) > 0)
|
||||
logger?.WriteLine(this.GetType().ToString(), $"Removed Task {task} {publication?.sortName} {publication?.internalId} from all Tasks.");
|
||||
else
|
||||
logger?.WriteLine(this.GetType().ToString(), $"No Task {task} {publication?.sortName} {publication?.downloadUrl} could be found.");
|
||||
logger?.WriteLine(this.GetType().ToString(), $"No Task {task} {publication?.sortName} {publication?.internalId} could be found.");
|
||||
}
|
||||
ExportData();
|
||||
}
|
||||
@ -289,19 +301,25 @@ public class TaskManager
|
||||
Environment.Exit(0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads stored data (settings, tasks) from file
|
||||
/// </summary>
|
||||
/// <param name="importFilePath">working directory, filename has to be data.json</param>
|
||||
public static SettingsData LoadData(string importFilePath)
|
||||
private void ImportData()
|
||||
{
|
||||
if (!File.Exists(importFilePath))
|
||||
return new SettingsData(Directory.GetCurrentDirectory(), null, null, new HashSet<TrangaTask>());
|
||||
logger?.WriteLine(this.GetType().ToString(), "Importing Data");
|
||||
string buffer;
|
||||
if (File.Exists(settings.tasksFilePath))
|
||||
{
|
||||
logger?.WriteLine(this.GetType().ToString(), $"Importing tasks from {settings.tasksFilePath}");
|
||||
buffer = File.ReadAllText(settings.tasksFilePath);
|
||||
this._allTasks = JsonConvert.DeserializeObject<HashSet<TrangaTask>>(buffer)!;
|
||||
}
|
||||
|
||||
string toRead = File.ReadAllText(importFilePath);
|
||||
SettingsData data = JsonConvert.DeserializeObject<SettingsData>(toRead)!;
|
||||
|
||||
return data;
|
||||
if (File.Exists(settings.knownPublicationsPath))
|
||||
{
|
||||
logger?.WriteLine(this.GetType().ToString(), $"Importing known publications from {settings.knownPublicationsPath}");
|
||||
buffer = File.ReadAllText(settings.knownPublicationsPath);
|
||||
Publication[] publications = JsonConvert.DeserializeObject<Publication[]>(buffer)!;
|
||||
foreach (Publication publication in publications)
|
||||
this._chapterCollection.TryAdd(publication, new List<Chapter>());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -309,38 +327,15 @@ public class TaskManager
|
||||
/// </summary>
|
||||
private void ExportData()
|
||||
{
|
||||
logger?.WriteLine(this.GetType().ToString(), $"Exporting data to {settings.settingsFilePath}");
|
||||
logger?.WriteLine(this.GetType().ToString(), $"Exporting settings to {settings.settingsFilePath}");
|
||||
File.WriteAllText(settings.settingsFilePath, JsonConvert.SerializeObject(settings));
|
||||
|
||||
logger?.WriteLine(this.GetType().ToString(), $"Exporting tasks to {settings.tasksFilePath}");
|
||||
File.WriteAllText(settings.tasksFilePath, JsonConvert.SerializeObject(this._allTasks));
|
||||
|
||||
|
||||
string serializedData = JsonConvert.SerializeObject(settings);
|
||||
|
||||
File.WriteAllText(settings.settingsFilePath, serializedData);
|
||||
logger?.WriteLine(this.GetType().ToString(), $"Exporting known publications to {settings.knownPublicationsPath}");
|
||||
File.WriteAllText(settings.knownPublicationsPath, JsonConvert.SerializeObject(this._chapterCollection.Keys.ToArray()));
|
||||
}
|
||||
|
||||
public class SettingsData
|
||||
{
|
||||
public string downloadLocation { get; private set; }
|
||||
public string settingsFilePath { get; }
|
||||
public Komga? komga { get; private set; }
|
||||
public HashSet<TrangaTask> allTasks { get; }
|
||||
|
||||
public SettingsData(string downloadLocation, string? settingsFilePath, Komga? komga, HashSet<TrangaTask> allTasks)
|
||||
{
|
||||
this.settingsFilePath = settingsFilePath ??
|
||||
Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
||||
"Tranga", "data.json");
|
||||
this.downloadLocation = downloadLocation;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
31
Tranga/TrangaSettings.cs
Normal file
31
Tranga/TrangaSettings.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Tranga;
|
||||
|
||||
public class TrangaSettings
|
||||
{
|
||||
public string downloadLocation { get; set; }
|
||||
public string workingDirectory { get; set; }
|
||||
[JsonIgnore]public string settingsFilePath => Path.Join(workingDirectory, "settings.json");
|
||||
[JsonIgnore]public string tasksFilePath => Path.Join(workingDirectory, "tasks.json");
|
||||
[JsonIgnore]public string knownPublicationsPath => Path.Join(workingDirectory, "knownPublications.json");
|
||||
public Komga? komga { get; set; }
|
||||
|
||||
public TrangaSettings(string downloadLocation, string workingDirectory, Komga? komga)
|
||||
{
|
||||
this.workingDirectory = workingDirectory;
|
||||
this.downloadLocation = downloadLocation;
|
||||
this.komga = komga;
|
||||
}
|
||||
|
||||
public static TrangaSettings LoadSettings(string importFilePath)
|
||||
{
|
||||
if (!File.Exists(importFilePath))
|
||||
return new TrangaSettings(Path.Join(Directory.GetCurrentDirectory(), "Downloads"), Directory.GetCurrentDirectory(), null);
|
||||
|
||||
string toRead = File.ReadAllText(importFilePath);
|
||||
TrangaSettings settings = JsonConvert.DeserializeObject<TrangaSettings>(toRead)!;
|
||||
|
||||
return settings;
|
||||
}
|
||||
}
|
@ -56,6 +56,6 @@ public class TrangaTask
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{task,-20} | {lastExecuted,-20} | {reoccurrence,-12} | {state,-10} | {connectorName,-15} | {publication?.sortName}";
|
||||
return $"{task}, {lastExecuted}, {reoccurrence}, {state} {(connectorName is not null ? $", {connectorName}" : "" )} {(publication is not null ? $", {publication?.sortName}": "")}";
|
||||
}
|
||||
}
|
4
Website/Dockerfile
Normal file
4
Website/Dockerfile
Normal file
@ -0,0 +1,4 @@
|
||||
FROM nginx:alpine3.17-slim
|
||||
COPY . /usr/share/nginx/html
|
||||
EXPOSE 80
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
120
Website/apiConnector.js
Normal file
120
Website/apiConnector.js
Normal file
@ -0,0 +1,120 @@
|
||||
let apiUri = `http://${window.location.host.split(':')[0]}:6531`
|
||||
|
||||
if(getCookie("apiUri") != ""){
|
||||
apiUri = getCookie("apiUri");
|
||||
}
|
||||
function getCookie(cname) {
|
||||
let name = cname + "=";
|
||||
let decodedCookie = decodeURIComponent(document.cookie);
|
||||
let ca = decodedCookie.split(';');
|
||||
for(let i = 0; i < ca.length; i++) {
|
||||
let c = ca[i];
|
||||
while (c.charAt(0) == ' ') {
|
||||
c = c.substring(1);
|
||||
}
|
||||
if (c.indexOf(name) == 0) {
|
||||
return c.substring(name.length, c.length);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
async function GetData(uri){
|
||||
let request = await fetch(uri, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Accept': 'application/json'
|
||||
}
|
||||
});
|
||||
let json = await request.json();
|
||||
return json;
|
||||
}
|
||||
|
||||
function PostData(uri){
|
||||
fetch(uri, {
|
||||
method: 'POST'
|
||||
});
|
||||
}
|
||||
|
||||
function DeleteData(uri){
|
||||
fetch(uri, {
|
||||
method: 'DELETE'
|
||||
});
|
||||
}
|
||||
|
||||
async function GetAvailableControllers(){
|
||||
var uri = apiUri + "/Tranga/GetAvailableControllers";
|
||||
let json = await GetData(uri);
|
||||
return json;
|
||||
}
|
||||
|
||||
async function GetPublication(connectorName, title){
|
||||
var uri = apiUri + `/Tranga/GetPublicationsFromConnector?connectorName=${connectorName}&title=${title}`;
|
||||
let json = await GetData(uri);
|
||||
return json;
|
||||
}
|
||||
|
||||
async function GetKnownPublications(){
|
||||
var uri = apiUri + "/Tranga/GetKnownPublications";
|
||||
let json = await GetData(uri);
|
||||
return json;
|
||||
}
|
||||
|
||||
async function GetTaskTypes(){
|
||||
var uri = apiUri + "/Tasks/GetTaskTypes";
|
||||
let json = await GetData(uri);
|
||||
return json;
|
||||
}
|
||||
async function GetRunningTasks(){
|
||||
var uri = apiUri + "/Tranga/GetRunningTasks";
|
||||
let json = await GetData(uri);
|
||||
return json;
|
||||
}
|
||||
|
||||
async function GetDownloadTasks(){
|
||||
var uri = apiUri + "/Tasks/Get?taskType=DownloadNewChapters";
|
||||
let json = await GetData(uri);
|
||||
return json;
|
||||
}
|
||||
|
||||
async function GetSettings(){
|
||||
var uri = apiUri + "/Settings/Get";
|
||||
let json = await GetData(uri);
|
||||
return json;
|
||||
}
|
||||
|
||||
async function GetKomgaTask(){
|
||||
var uri = apiUri + "/Tasks/Get?taskType=UpdateKomgaLibrary";
|
||||
let json = await GetData(uri);
|
||||
return json;
|
||||
}
|
||||
|
||||
function CreateTask(taskType, reoccurrence, connectorName, publicationId, language){
|
||||
var uri = apiUri + `/Tasks/Create?taskType=${taskType}&connectorName=${connectorName}&publicationId=${publicationId}&reoccurrenceTime=${reoccurrence}&language=${language}`;
|
||||
PostData(uri);
|
||||
}
|
||||
|
||||
function StartTask(taskType, connectorName, publicationId){
|
||||
var uri = apiUri + `/Tasks/Start?taskType=${taskType}&connectorName=${connectorName}&publicationId=${publicationId}`;
|
||||
PostData(uri);
|
||||
}
|
||||
|
||||
function EnqueueTask(taskType, connectorName, publicationId){
|
||||
var uri = apiUri + `/Queue/Enqueue?taskType=${taskType}&connectorName=${connectorName}&publicationId=${publicationId}`;
|
||||
PostData(uri);
|
||||
}
|
||||
|
||||
function UpdateSettings(downloadLocation, komgaUrl, komgaAuth){
|
||||
var uri = apiUri + `/Settings/Update?downloadLocation=${downloadLocation}&komgaUrl=${komgaUrl}&komgaAuth=${komgaAuth}`;
|
||||
PostData(uri);
|
||||
}
|
||||
|
||||
function DeleteTask(taskType, connectorName, publicationId){
|
||||
var uri = apiUri + `/Tasks/Delete?taskType=${taskType}&connectorName=${connectorName}&publicationId=${publicationId}`;
|
||||
DeleteData(uri);
|
||||
}
|
||||
|
||||
function DequeueTask(taskType, connectorName, publicationId){
|
||||
var uri = apiUri + `/Queue/Dequeue?taskType=${taskType}&connectorName=${connectorName}&publicationId=${publicationId}`;
|
||||
DeleteData(uri);
|
||||
}
|
101
Website/index.html
Normal file
101
Website/index.html
Normal file
@ -0,0 +1,101 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Tranga</title>
|
||||
<link rel="stylesheet" href="style.css">
|
||||
</head>
|
||||
<body>
|
||||
<topbar>
|
||||
<titlebox>
|
||||
<img src="media/blahaj.png">
|
||||
<span>Tranga</span>
|
||||
</titlebox>
|
||||
<spacer></spacer>
|
||||
<searchdiv>
|
||||
<input id="searchbox" placeholder="Filter" type="text">
|
||||
</searchdiv>
|
||||
<img id="settingscog" src="media/settings-cogwheel.svg" height="100%" alt="settingscog">
|
||||
</topbar>
|
||||
<viewport>
|
||||
<sidebar>
|
||||
<background-placeholder></background-placeholder>
|
||||
|
||||
<spacer></spacer>
|
||||
<p style="text-align: center">Made with Blåhaj 🦈</p>
|
||||
</sidebar>
|
||||
<content>
|
||||
<div id="addPublication">
|
||||
<p>+</p>
|
||||
</div>
|
||||
<publication>
|
||||
<img src="media/cover.jpg">
|
||||
<publication-information>
|
||||
<connector-name class="pill">MangaDex</connector-name>
|
||||
<publication-name>Tensei Pandemic</publication-name>
|
||||
</publication-information>
|
||||
</publication>
|
||||
</content>
|
||||
|
||||
<popup id="addTaskPopup">
|
||||
<blur-background id="blurBackgroundTaskPopup"></blur-background>
|
||||
<addtask-window>
|
||||
<window-titlebar>
|
||||
<p>Add Task</p>
|
||||
<img id="closePopupImg" src="media/close-x.svg" alt="Close">
|
||||
</window-titlebar>
|
||||
<window-content>
|
||||
<addtask-settings>
|
||||
<addtask-setting><label for="selectReccurrence">Recurrence</label><input id="selectReccurrence" type="time" value="01:00:00" step="3600"></addtask-setting>
|
||||
<addtask-setting><label for="connectors">Connector</label>
|
||||
<select id="connectors">
|
||||
<option value=""></option>
|
||||
</select>
|
||||
</addtask-setting>
|
||||
<addtask-setting><label for="searchPublicationQuery">Search Title</label><input id="searchPublicationQuery" type="text"></addtask-setting>
|
||||
<input type="submit" value="Search" onclick="NewSearch();">
|
||||
</addtask-settings>
|
||||
<div id="taskSelectOutput"></div>
|
||||
</window-content>
|
||||
</addtask-window>
|
||||
</popup>
|
||||
<popup id="publicationViewerPopup">
|
||||
<blur-background id="blurBackgroundPublicationPopup"></blur-background>
|
||||
<publication-viewer>
|
||||
<img id="pubviewcover" src="media/cover.jpg" alt="cover">
|
||||
<publication-information>
|
||||
<publication-name id="publicationViewerName">Tensei Pandemic</publication-name>
|
||||
<publication-author id="publicationViewerAuthor">Imamura Hinata</publication-author>
|
||||
<publication-description id="publicationViewerDescription">Imamura Hinata is a high school boy with a cute appearance.
|
||||
Since his trauma with the first love, he wanted to be more manly than anybody else. But one day he woke up to something different…
|
||||
The total opposite of his ideal male body!
|
||||
Pandemic love comedy!
|
||||
</publication-description>
|
||||
<publication-delete>Delete Task ❌</publication-delete>
|
||||
<publication-add>Add Task ➕</publication-add>
|
||||
</publication-information>
|
||||
</publication-viewer>
|
||||
</popup>
|
||||
|
||||
</viewport>
|
||||
|
||||
<settingstab id="settingstab">
|
||||
<span class="title">Download Location:</span>
|
||||
<span id="downloadLocation"></span>
|
||||
<span class="title">API-URI</span>
|
||||
<label for="settingApiUri"></label><input placeholder="https://" type="text" id="settingApiUri">
|
||||
<komga-settings>
|
||||
<span class="title">Komga</span>
|
||||
<div>Configured: <span id="komgaConfigured">✅❌</span></div>
|
||||
<label for="komgaUrl"></label><input placeholder="URL" id="komgaUrl" type="text">
|
||||
<label for="komgaUsername"></label><input placeholder="Username" id="komgaUsername" type="text">
|
||||
<label for="komgaPassword"></label><input placeholder="Password" id="komgaPassword" type="password">
|
||||
<div><label for="komgaUpdateTime" style="margin-right: 5px;">Update Time</label><input id="komgaUpdateTime" type="time" value="00:01:00" step="10"></div>
|
||||
<input type="submit" value="Update" onclick="UpdateKomgaSettings()">
|
||||
</komga-settings>
|
||||
</settingstab>
|
||||
|
||||
<script src="apiConnector.js"></script>
|
||||
<script src="interaction.js"></script>
|
||||
</body>
|
||||
</html>
|
288
Website/interaction.js
Normal file
288
Website/interaction.js
Normal file
@ -0,0 +1,288 @@
|
||||
const slideInRight = [
|
||||
{ right: "-20rem" },
|
||||
{ right: "0" }
|
||||
];
|
||||
|
||||
const slideInRightTiming = {
|
||||
duration: 200,
|
||||
iterations: 1,
|
||||
fill: "forwards",
|
||||
easing: "ease-out"
|
||||
}
|
||||
|
||||
const slideOutRightTiming = {
|
||||
direction: "reverse",
|
||||
duration: 200,
|
||||
iterations: 1,
|
||||
fill: "forwards",
|
||||
easing: "ease-in"
|
||||
}
|
||||
|
||||
let publications = [];
|
||||
let tasks = [];
|
||||
let toEditId;
|
||||
|
||||
const searchPublicationQuery = document.querySelector("#searchPublicationQuery");
|
||||
const selectPublication = document.querySelector("#taskSelectOutput");
|
||||
const connectorSelect = document.querySelector("#connectors");
|
||||
const settingsTab = document.querySelector("#settingstab");
|
||||
const settingsCog = document.querySelector("#settingscog");
|
||||
const selectRecurrence = document.querySelector("#selectReccurrence");
|
||||
const tasksContent = document.querySelector("content");
|
||||
const addTaskPopup = document.querySelector("#addTaskPopup");
|
||||
const publicationViewerPopup = document.querySelector("#publicationViewerPopup");
|
||||
const publicationViewerWindow = document.querySelector("publication-viewer");
|
||||
const publicationViewerDescription = document.querySelector("#publicationViewerDescription");
|
||||
const publicationViewerName = document.querySelector("#publicationViewerName");
|
||||
const publicationViewerAuthor = document.querySelector("#publicationViewerAuthor");
|
||||
const pubviewcover = document.querySelector("#pubviewcover");
|
||||
const publicationDelete = document.querySelector("publication-delete");
|
||||
const publicationAdd = document.querySelector("publication-add");
|
||||
const closetaskpopup = document.querySelector("#closePopupImg");
|
||||
const settingDownloadLocation = document.querySelector("#downloadLocation");
|
||||
const settingKomgaUrl = document.querySelector("#komgaUrl");
|
||||
const settingKomgaUser = document.querySelector("#komgaUsername");
|
||||
const settingKomgaPass = document.querySelector("#komgaPassword");
|
||||
const settingKomgaTime = document.querySelector("#komgaUpdateTime");
|
||||
const settingKomgaConfigured = document.querySelector("#komgaConfigured");
|
||||
const settingApiUri = document.querySelector("#settingApiUri");
|
||||
|
||||
|
||||
settingsCog.addEventListener("click", () => OpenSettings());
|
||||
closetaskpopup.addEventListener("click", () => HideAddTaskPopup());
|
||||
document.querySelector("#blurBackgroundTaskPopup").addEventListener("click", () => HideAddTaskPopup());
|
||||
document.querySelector("#blurBackgroundPublicationPopup").addEventListener("click", () => HidePublicationPopup());
|
||||
publicationDelete.addEventListener("click", () => DeleteTaskClick());
|
||||
publicationAdd.addEventListener("click", () => AddTaskClick());
|
||||
settingApiUri.addEventListener("keypress", (event) => {
|
||||
if(event.key === "Enter"){
|
||||
apiUri = settingApiUri.value;
|
||||
setTimeout(() => GetSettingsClick(), 100);
|
||||
document.cookie = `apiUri=${apiUri};`;
|
||||
}
|
||||
});
|
||||
searchPublicationQuery.addEventListener("keypress", (event) => {
|
||||
if(event.key === "Enter"){
|
||||
NewSearch();
|
||||
}
|
||||
});
|
||||
|
||||
let availableConnectors;
|
||||
GetAvailableControllers()
|
||||
.then(json => availableConnectors = json)
|
||||
.then(json =>
|
||||
json.forEach(connector => {
|
||||
var option = document.createElement('option');
|
||||
option.value = connector;
|
||||
option.innerText = connector;
|
||||
connectorSelect.appendChild(option);
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
function NewSearch(){
|
||||
//Disable inputs
|
||||
selectRecurrence.disabled = true;
|
||||
connectorSelect.disabled = true;
|
||||
searchPublicationQuery.disabled = true;
|
||||
|
||||
//Empty previous results
|
||||
selectPublication.replaceChildren();
|
||||
GetPublication(connectorSelect.value, searchPublicationQuery.value)
|
||||
.then(json =>
|
||||
json.forEach(publication => {
|
||||
var option = CreatePublication(publication, connectorSelect.value);
|
||||
option.addEventListener("click", (mouseEvent) => {
|
||||
ShowPublicationViewerWindow(publication.internalId, mouseEvent, true);
|
||||
});
|
||||
selectPublication.appendChild(option);
|
||||
}
|
||||
))
|
||||
.then(() => {
|
||||
//Re-enable inputs
|
||||
selectRecurrence.disabled = false;
|
||||
connectorSelect.disabled = false;
|
||||
searchPublicationQuery.disabled = false;
|
||||
});
|
||||
}
|
||||
|
||||
//Returns a new "Publication" Item to display in the tasks section
|
||||
function CreatePublication(publication, connector){
|
||||
var publicationElement = document.createElement('publication');
|
||||
publicationElement.setAttribute("id", publication.internalId);
|
||||
var img = document.createElement('img');
|
||||
img.src = publication.posterUrl;
|
||||
publicationElement.appendChild(img);
|
||||
var info = document.createElement('publication-information');
|
||||
var connectorName = document.createElement('connector-name');
|
||||
connectorName.innerText = connector;
|
||||
connectorName.className = "pill";
|
||||
info.appendChild(connectorName);
|
||||
var publicationName = document.createElement('publication-name');
|
||||
publicationName.innerText = publication.sortName;
|
||||
info.appendChild(publicationName);
|
||||
publicationElement.appendChild(info);
|
||||
if(publications.filter(pub => pub.internalId === publication.internalId) < 1)
|
||||
publications.push(publication);
|
||||
return publicationElement;
|
||||
}
|
||||
|
||||
function DeleteTaskClick(){
|
||||
taskToDelete = tasks.filter(tTask => tTask.publication.internalId === toEditId)[0];
|
||||
DeleteTask("DownloadNewChapters", taskToDelete.connectorName, toEditId);
|
||||
HidePublicationPopup();
|
||||
}
|
||||
|
||||
function AddTaskClick(){
|
||||
CreateTask("DownloadNewChapters", selectRecurrence.value, connectorSelect.value, toEditId, "en")
|
||||
HideAddTaskPopup();
|
||||
HidePublicationPopup();
|
||||
}
|
||||
|
||||
let slideIn = true;
|
||||
function slide() {
|
||||
if (slideIn)
|
||||
settingsTab.animate(slideInRight, slideInRightTiming);
|
||||
else
|
||||
settingsTab.animate(slideInRight, slideOutRightTiming);
|
||||
slideIn = !slideIn;
|
||||
}
|
||||
|
||||
function ResetContent(){
|
||||
//Delete everything
|
||||
tasksContent.replaceChildren();
|
||||
|
||||
//Add "Add new Task" Button
|
||||
var add = document.createElement("div");
|
||||
add.setAttribute("id", "addPublication")
|
||||
var plus = document.createElement("p");
|
||||
plus.innerText = "+";
|
||||
add.appendChild(plus);
|
||||
add.addEventListener("click", () => ShowNewTaskWindow());
|
||||
tasksContent.appendChild(add);
|
||||
}
|
||||
function ShowPublicationViewerWindow(publicationId, event, add){
|
||||
//Set position to mouse-position
|
||||
publicationViewerWindow.style.top = `${event.clientY - 60}px`;
|
||||
publicationViewerWindow.style.left = `${event.clientX}px`;
|
||||
|
||||
//Edit information inside the window
|
||||
var publication = publications.filter(pub => pub.internalId === publicationId)[0];
|
||||
publicationViewerName.innerText = publication.sortName;
|
||||
publicationViewerDescription.innerText = publication.description;
|
||||
publicationViewerAuthor.innerText = publication.author;
|
||||
pubviewcover.src = publication.posterUrl;
|
||||
toEditId = publicationId;
|
||||
|
||||
//Check what action should be listed
|
||||
if(add){
|
||||
publicationAdd.style.display = "block";
|
||||
publicationDelete.style.display = "none";
|
||||
}
|
||||
else{
|
||||
publicationAdd.style.display = "none";
|
||||
publicationDelete.style.display = "block";
|
||||
}
|
||||
|
||||
//Show popup
|
||||
publicationViewerPopup.style.display = "block";
|
||||
}
|
||||
|
||||
function HidePublicationPopup(){
|
||||
publicationViewerPopup.style.display = "none";
|
||||
}
|
||||
|
||||
function ShowNewTaskWindow(){
|
||||
selectPublication.replaceChildren();
|
||||
addTaskPopup.style.display = "block";
|
||||
}
|
||||
function HideAddTaskPopup(){
|
||||
addTaskPopup.style.display = "none";
|
||||
}
|
||||
|
||||
|
||||
const fadeIn = [
|
||||
{ opacity: "0" },
|
||||
{ opacity: "1" }
|
||||
];
|
||||
|
||||
const fadeInTiming = {
|
||||
duration: 50,
|
||||
iterations: 1,
|
||||
fill: "forwards"
|
||||
}
|
||||
|
||||
function OpenSettings(){
|
||||
GetSettingsClick();
|
||||
slide();
|
||||
}
|
||||
|
||||
function GetSettingsClick(){
|
||||
settingApiUri.value = "";
|
||||
settingKomgaUrl.value = "";
|
||||
settingKomgaUser.value = "";
|
||||
settingKomgaPass.value = "";
|
||||
|
||||
settingApiUri.placeholder = apiUri;
|
||||
|
||||
GetSettings().then(json => {
|
||||
settingDownloadLocation.innerText = json.downloadLocation;
|
||||
if(json.komga != null)
|
||||
settingKomgaUrl.placeholder = json.komga.baseUrl;
|
||||
});
|
||||
|
||||
GetKomgaTask().then(json => {
|
||||
if(json.length > 0)
|
||||
settingKomgaConfigured.innerText = "✅";
|
||||
else
|
||||
settingKomgaConfigured.innerText = "❌";
|
||||
});
|
||||
}
|
||||
|
||||
function UpdateKomgaSettings(){
|
||||
var auth = utf8_to_b64(`${settingKomgaUser.value}:${settingKomgaPass.value}`);
|
||||
console.log(auth);
|
||||
UpdateSettings("", settingKomgaUrl.value, auth);
|
||||
CreateTask("UpdateKomgaLibrary", settingKomgaTime.value, "","","");
|
||||
setTimeout(() => GetSettingsClick(), 500);
|
||||
}
|
||||
|
||||
function utf8_to_b64( str ) {
|
||||
return window.btoa(unescape(encodeURIComponent( str )));
|
||||
}
|
||||
|
||||
//Resets the tasks shown
|
||||
ResetContent();
|
||||
//Get Tasks and show them
|
||||
GetDownloadTasks()
|
||||
.then(json => json.forEach(task => {
|
||||
var publication = CreatePublication(task.publication, task.connectorName);
|
||||
publication.addEventListener("click", (event) => ShowPublicationViewerWindow(task.publication.internalId, event, false));
|
||||
tasksContent.appendChild(publication);
|
||||
tasks.push(task);
|
||||
}));
|
||||
|
||||
setInterval(() => {
|
||||
//Tasks from API
|
||||
var cTasks = [];
|
||||
GetDownloadTasks()
|
||||
.then(json => json.forEach(task => cTasks.push(task)))
|
||||
.then(() => {
|
||||
//Only update view if tasks-amount has changed
|
||||
if(tasks.length != cTasks.length) {
|
||||
//Resets the tasks shown
|
||||
ResetContent();
|
||||
//Add all currenttasks to view
|
||||
cTasks.forEach(task => {
|
||||
var publication = CreatePublication(task.publication, task.connectorName);
|
||||
publication.addEventListener("click", (event) => ShowPublicationViewerWindow(task.publication.internalId, event, false));
|
||||
tasksContent.appendChild(publication);
|
||||
})
|
||||
|
||||
tasks = cTasks;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
}, 1000);
|
BIN
Website/media/blahaj.png
Normal file
BIN
Website/media/blahaj.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 124 KiB |
4
Website/media/close-x.svg
Normal file
4
Website/media/close-x.svg
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||
<svg width="800px" height="800px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M5.29289 5.29289C5.68342 4.90237 6.31658 4.90237 6.70711 5.29289L12 10.5858L17.2929 5.29289C17.6834 4.90237 18.3166 4.90237 18.7071 5.29289C19.0976 5.68342 19.0976 6.31658 18.7071 6.70711L13.4142 12L18.7071 17.2929C19.0976 17.6834 19.0976 18.3166 18.7071 18.7071C18.3166 19.0976 17.6834 19.0976 17.2929 18.7071L12 13.4142L6.70711 18.7071C6.31658 19.0976 5.68342 19.0976 5.29289 18.7071C4.90237 18.3166 4.90237 17.6834 5.29289 17.2929L10.5858 12L5.29289 6.70711C4.90237 6.31658 4.90237 5.68342 5.29289 5.29289Z" fill="#0F1729"/>
|
||||
</svg>
|
After Width: | Height: | Size: 804 B |
21
Website/media/settings-cogwheel.svg
Normal file
21
Website/media/settings-cogwheel.svg
Normal file
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg fill="#000000" version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
width="800px" height="800px" viewBox="0 0 93.5 93.5" xml:space="preserve">
|
||||
<g>
|
||||
<g>
|
||||
<path d="M93.5,40.899c0-2.453-1.995-4.447-4.448-4.447H81.98c-0.74-2.545-1.756-5.001-3.035-7.331l4.998-5
|
||||
c0.826-0.827,1.303-1.973,1.303-3.146c0-1.19-0.462-2.306-1.303-3.146L75.67,9.555c-1.613-1.615-4.673-1.618-6.29,0l-5,5
|
||||
c-2.327-1.28-4.786-2.296-7.332-3.037v-7.07C57.048,1.995,55.053,0,52.602,0H40.899c-2.453,0-4.447,1.995-4.447,4.448v7.071
|
||||
c-2.546,0.741-5.005,1.757-7.333,3.037l-5-5c-1.68-1.679-4.609-1.679-6.288,0L9.555,17.83c-1.734,1.734-1.734,4.555,0,6.289
|
||||
l4.999,5c-1.279,2.33-2.295,4.788-3.036,7.333h-7.07C1.995,36.452,0,38.447,0,40.899V52.6c0,2.453,1.995,4.447,4.448,4.447h7.071
|
||||
c0.74,2.545,1.757,5.003,3.036,7.332l-4.998,4.999c-0.827,0.827-1.303,1.974-1.303,3.146c0,1.189,0.462,2.307,1.302,3.146
|
||||
l8.274,8.273c1.614,1.615,4.674,1.619,6.29,0l5-5c2.328,1.279,4.786,2.297,7.333,3.037v7.071c0,2.453,1.995,4.448,4.447,4.448
|
||||
h11.702c2.453,0,4.446-1.995,4.446-4.448V81.98c2.546-0.74,5.005-1.756,7.332-3.037l5,5c1.681,1.68,4.608,1.68,6.288,0
|
||||
l8.275-8.273c1.734-1.734,1.734-4.555,0-6.289l-4.998-5.001c1.279-2.329,2.295-4.787,3.035-7.332h7.071
|
||||
c2.453,0,4.448-1.995,4.448-4.446V40.899z M62.947,46.75c0,8.932-7.266,16.197-16.197,16.197c-8.931,0-16.197-7.266-16.197-16.197
|
||||
c0-8.931,7.266-16.197,16.197-16.197C55.682,30.553,62.947,37.819,62.947,46.75z"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.7 KiB |
422
Website/style.css
Normal file
422
Website/style.css
Normal file
@ -0,0 +1,422 @@
|
||||
:root{
|
||||
--background-color: #eee;
|
||||
--second-background-color: #fff;
|
||||
--primary-color: #f5a9b8;
|
||||
--secondary-color: #5bcefa;
|
||||
--accent-color: #fff;
|
||||
--topbar-height: 60px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body{
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
display: flex;
|
||||
flex-flow: column;
|
||||
flex-wrap: nowrap;
|
||||
height: 100vh;
|
||||
background-color: var(--background-color);
|
||||
font-family: "Inter", sans-serif;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
background-placeholder{
|
||||
background-color: var(--second-background-color);
|
||||
opacity: 1;
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border-radius: 0 0 5px 0;
|
||||
z-index: -1;
|
||||
}
|
||||
|
||||
topbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height: var(--topbar-height);
|
||||
background-color: var(--secondary-color);
|
||||
}
|
||||
|
||||
titlebox {
|
||||
position: relative;
|
||||
display: flex;
|
||||
margin: 0 0 0 40px;
|
||||
height: 100%;
|
||||
align-items:center;
|
||||
justify-content:center;
|
||||
}
|
||||
|
||||
titlebox span{
|
||||
font-size: 24pt;
|
||||
font-weight: bold;
|
||||
background: linear-gradient(150deg, var(--primary-color), var(--accent-color));
|
||||
-webkit-background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
titlebox img {
|
||||
height: 100%;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
spacer{
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
searchdiv{
|
||||
display: block;
|
||||
margin: 0 10px 0 0;
|
||||
}
|
||||
|
||||
#searchbox {
|
||||
padding: 6px 8px;
|
||||
border: 0;
|
||||
border-radius: 3px;
|
||||
font-size: 14pt;
|
||||
width: 250px;
|
||||
}
|
||||
|
||||
#settingscog {
|
||||
cursor: pointer;
|
||||
margin: 0px 30px;
|
||||
height: calc(100% - 40px);
|
||||
filter: invert(100%) sepia(0%) saturate(7465%) hue-rotate(115deg) brightness(116%) contrast(101%);
|
||||
}
|
||||
|
||||
viewport {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-flow: row;
|
||||
flex-wrap: nowrap;
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
sidebar{
|
||||
position: relative;
|
||||
width: 20rem;
|
||||
margin-bottom: 20px;
|
||||
border-radius: 0 0 5px 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
}
|
||||
|
||||
content {
|
||||
position: relative;
|
||||
flex-grow: 1;
|
||||
margin: 0 10px 10px 10px;
|
||||
border-radius: 5px;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
justify-content: start;
|
||||
align-content: start;
|
||||
}
|
||||
|
||||
settingstab{
|
||||
position: absolute;
|
||||
right: -20rem;
|
||||
bottom: 0;
|
||||
background-color: rgba(0,0,0,0.5);
|
||||
width: 20rem;
|
||||
height: calc(100% - var(--topbar-height) - 40px);
|
||||
margin-bottom: 10px;
|
||||
border-radius: 5px 0 0 5px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
|
||||
settingstab > * {
|
||||
margin: 0 20px;
|
||||
}
|
||||
|
||||
settingstab input {
|
||||
padding: 3px;
|
||||
border-radius: 3px;
|
||||
border: 0;
|
||||
margin: 2px 20px;
|
||||
}
|
||||
|
||||
settingstab .title {
|
||||
font-size: 14pt;
|
||||
font-weight: bolder;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
komga-settings {
|
||||
margin-top: 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
|
||||
komga-settings input {
|
||||
margin: 2px 0;
|
||||
}
|
||||
|
||||
#addPublication {
|
||||
cursor: pointer;
|
||||
background-color: var(--secondary-color);
|
||||
width: 180px;
|
||||
height: 300px;
|
||||
border-radius: 5px;
|
||||
margin: 10px 10px;
|
||||
padding: 15px 20px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
#addPublication p{
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
font-size: 150pt;
|
||||
vertical-align: middle;
|
||||
line-height: 300px;
|
||||
margin: 0;
|
||||
color: var(--accent-color);
|
||||
}
|
||||
|
||||
.pill {
|
||||
flex-grow: 0;
|
||||
height: 14pt;
|
||||
font-size: 12pt;
|
||||
border-radius: 9pt;
|
||||
background-color: var(--primary-color);
|
||||
padding: 2pt 20px;
|
||||
}
|
||||
|
||||
publication{
|
||||
cursor: pointer;
|
||||
background-color: var(--secondary-color);
|
||||
width: 180px;
|
||||
height: 300px;
|
||||
border-radius: 5px;
|
||||
margin: 10px 10px;
|
||||
padding: 15px 20px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
publication::after{
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 0; top: 0;
|
||||
border-radius: 5px;
|
||||
width: 100%; height: 100%;
|
||||
background: linear-gradient(rgba(0, 0, 0, 0.5),rgba(0, 0, 0, 0.1));
|
||||
}
|
||||
|
||||
publication-information {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: start;
|
||||
}
|
||||
|
||||
publication-information * {
|
||||
z-index: 1;
|
||||
color: var(--accent-color);
|
||||
}
|
||||
|
||||
connector-name{
|
||||
width: fit-content;
|
||||
margin: 10px 0;
|
||||
}
|
||||
|
||||
publication-name{
|
||||
width: fit-content;
|
||||
font-size: 16pt;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
publication img {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
popup{
|
||||
display: none;
|
||||
width: 100%;
|
||||
min-height: 100%;
|
||||
top: 0;
|
||||
left: 0;
|
||||
position: absolute;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
blur-background {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
left: 0;
|
||||
background-color: black;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
addtask-window {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-wrap: nowrap;
|
||||
position: absolute;
|
||||
left: 12.5%;
|
||||
top: 15%;
|
||||
width: 75%;
|
||||
min-height: 70%;
|
||||
max-height: 80%;
|
||||
padding: 0;
|
||||
background-color: var(--accent-color);
|
||||
z-index: 5;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
window-titlebar {
|
||||
width: 100%;
|
||||
height: 60px;
|
||||
background-color: var(--primary-color);
|
||||
border-radius: 5px 5px 0 0;
|
||||
color: var(--accent-color);
|
||||
display: flex block;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
window-titlebar p {
|
||||
margin: 0 30px;
|
||||
font-size: 14pt;
|
||||
font-weight: bolder;
|
||||
letter-spacing: 1px;
|
||||
}
|
||||
|
||||
window-titlebar #closePopupImg {
|
||||
height: 70%;
|
||||
cursor: pointer;
|
||||
margin-right: 20px;
|
||||
filter: invert(100%) sepia(0%) saturate(100%) hue-rotate(115deg) brightness(116%) contrast(101%);
|
||||
}
|
||||
|
||||
window-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 20px 5%;
|
||||
overflow-x: scroll;
|
||||
}
|
||||
|
||||
addtask-settings{
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
addtask-settings select, addtask-settings input{
|
||||
padding: 5px;
|
||||
font-size: 10pt;
|
||||
border: 1px solid rgba(0,0,0,0.2);
|
||||
border-radius: 3px;
|
||||
background-color: transparent;
|
||||
margin: 10px 0;
|
||||
width: 150px;
|
||||
}
|
||||
|
||||
addtask-settings label {
|
||||
font-weight: bolder;
|
||||
margin: 0 5px;
|
||||
}
|
||||
|
||||
addtask-settings addtask-setting{
|
||||
margin: 0 15px;
|
||||
}
|
||||
|
||||
#taskSelectOutput{
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
justify-content: start;
|
||||
align-content: start;
|
||||
}
|
||||
|
||||
#publicationViewerPopup{
|
||||
z-index: 6;
|
||||
}
|
||||
|
||||
publication-viewer{
|
||||
display: block;
|
||||
width: 500px;
|
||||
height: 300px;
|
||||
position: absolute;
|
||||
top: 200px;
|
||||
left: 400px;
|
||||
background-color: var(--accent-color);
|
||||
border-radius: 5px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
publication-viewer{
|
||||
padding: 30px;
|
||||
}
|
||||
|
||||
publication-viewer::after{
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 0; top: 0;
|
||||
border-radius: 5px;
|
||||
width: 100%; height: 100%;
|
||||
background: rgba(0,0,0,0.8);
|
||||
backdrop-filter: blur(3px);
|
||||
}
|
||||
|
||||
publication-viewer img {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
min-height: 100%;
|
||||
max-width: 100%;
|
||||
border-radius: 5px;
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
publication-viewer publication-information publication-name{
|
||||
margin: 5px 0;
|
||||
}
|
||||
|
||||
publication-viewer publication-information publication-author {
|
||||
margin: 5px 0;
|
||||
}
|
||||
|
||||
publication-viewer publication-information publication-author::before {
|
||||
content: "Author: ";
|
||||
}
|
||||
|
||||
publication-viewer publication-information publication-description::before {
|
||||
content: "Description";
|
||||
display: block;
|
||||
font-weight: bolder;
|
||||
}
|
||||
|
||||
publication-viewer publication-information publication-description {
|
||||
font-size: 12pt;
|
||||
margin: 5px 0;
|
||||
max-height: 200px;
|
||||
overflow-x: scroll;
|
||||
}
|
||||
|
||||
publication-viewer publication-information publication-delete {
|
||||
position: absolute;
|
||||
bottom: 0px;
|
||||
right: 0px;
|
||||
color: red;
|
||||
margin: 20px;
|
||||
font-size: 16pt;
|
||||
}
|
||||
|
||||
publication-viewer publication-information publication-add {
|
||||
position: absolute;
|
||||
bottom: 0px;
|
||||
right: 0px;
|
||||
color: limegreen;
|
||||
margin: 20px;
|
||||
font-size: 16pt;
|
||||
}
|
15
docker-compose.yaml
Normal file
15
docker-compose.yaml
Normal file
@ -0,0 +1,15 @@
|
||||
services:
|
||||
tranga-api:
|
||||
image: glax/tranga-api:latest
|
||||
container_name: tranga-api
|
||||
volumes:
|
||||
- ./tranga:/usr/share/Tranga-API
|
||||
- ./Manga:/Manga
|
||||
ports:
|
||||
- 6531:80
|
||||
restart: unless-stopped
|
||||
tranga-website:
|
||||
image: glax/tranga-website:latest
|
||||
container_name: tranga-website
|
||||
ports:
|
||||
- 9555:80
|
Reference in New Issue
Block a user