mirror of
https://github.com/C9Glax/tranga.git
synced 2025-06-14 07:17:54 +02:00
Merge remote-tracking branch 'upstream/cuttingedge' into cuttingedge
This commit is contained in:
@ -206,6 +206,9 @@ public class Server : GlobalBase
|
||||
case "Settings/customRequestLimit":
|
||||
SendResponse(HttpStatusCode.OK, response, settings.requestLimits);
|
||||
break;
|
||||
case "Settings/AprilFoolsMode":
|
||||
SendResponse(HttpStatusCode.OK, response, settings.aprilFoolsMode);
|
||||
break;
|
||||
case "NotificationConnectors":
|
||||
SendResponse(HttpStatusCode.OK, response, notificationConnectors);
|
||||
break;
|
||||
@ -397,7 +400,7 @@ public class Server : GlobalBase
|
||||
case "Settings/UpdateDownloadLocation":
|
||||
if (!requestVariables.TryGetValue("downloadLocation", out string? downloadLocation) ||
|
||||
!requestVariables.TryGetValue("moveFiles", out string? moveFilesStr) ||
|
||||
!Boolean.TryParse(moveFilesStr, out bool moveFiles))
|
||||
!bool.TryParse(moveFilesStr, out bool moveFiles))
|
||||
{
|
||||
SendResponse(HttpStatusCode.BadRequest, response);
|
||||
break;
|
||||
@ -405,6 +408,16 @@ public class Server : GlobalBase
|
||||
settings.UpdateDownloadLocation(downloadLocation, moveFiles);
|
||||
SendResponse(HttpStatusCode.Accepted, response);
|
||||
break;
|
||||
case "Settings/AprilFoolsMode":
|
||||
if (!requestVariables.TryGetValue("enabled", out string? aprilFoolsModeEnabledStr) ||
|
||||
bool.TryParse(aprilFoolsModeEnabledStr, out bool aprilFoolsModeEnabled))
|
||||
{
|
||||
SendResponse(HttpStatusCode.BadRequest, response);
|
||||
break;
|
||||
}
|
||||
settings.UpdateAprilFoolsMode(aprilFoolsModeEnabled);
|
||||
SendResponse(HttpStatusCode.Accepted, response);
|
||||
break;
|
||||
/*case "Settings/UpdateWorkingDirectory":
|
||||
if (!requestVariables.TryGetValue("workingDirectory", out string? workingDirectory))
|
||||
{
|
||||
|
@ -73,10 +73,23 @@ public partial class Tranga : GlobalBase
|
||||
{
|
||||
while (keepRunning)
|
||||
{
|
||||
jobBoss.CheckJobs();
|
||||
if(!settings.aprilFoolsMode || !IsAprilFirst())
|
||||
jobBoss.CheckJobs();
|
||||
else
|
||||
Log("April Fools Mode in Effect");
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
});
|
||||
t.Start();
|
||||
}
|
||||
|
||||
private bool IsAprilFirst()
|
||||
{
|
||||
//UTC 01 Apr +-12hrs
|
||||
DateTime start = new DateTime(DateTime.Now.Year, 03, 31, 12, 0, 0, DateTimeKind.Utc);
|
||||
DateTime end = new DateTime(DateTime.Now.Year, 04, 02, 12, 0, 0, DateTimeKind.Utc);
|
||||
if (DateTime.UtcNow > start && DateTime.UtcNow < end)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
@ -17,16 +17,16 @@ public partial class Tranga : GlobalBase
|
||||
|
||||
string[]? consoleLogger = GetArg(args, ArgEnum.ConsoleLogger);
|
||||
string[]? fileLogger = GetArg(args, ArgEnum.FileLogger);
|
||||
string? filePath = GetArg(args, ArgEnum.FileLoggerPath)?[0];
|
||||
if (filePath is not null && !Directory.Exists(new FileInfo(filePath).DirectoryName))
|
||||
Directory.CreateDirectory(new FileInfo(filePath).DirectoryName!);
|
||||
string? directoryPath = GetArg(args, ArgEnum.FileLoggerPath)?[0];
|
||||
if (directoryPath is not null && !Directory.Exists(directoryPath))
|
||||
Directory.CreateDirectory(directoryPath);
|
||||
|
||||
List<Logger.LoggerType> enabledLoggers = new();
|
||||
if(consoleLogger is not null)
|
||||
enabledLoggers.Add(Logger.LoggerType.ConsoleLogger);
|
||||
if (fileLogger is not null)
|
||||
enabledLoggers.Add(Logger.LoggerType.FileLogger);
|
||||
Logger logger = new(enabledLoggers.ToArray(), Console.Out, Console.OutputEncoding, filePath);
|
||||
Logger logger = new(enabledLoggers.ToArray(), Console.Out, Console.OutputEncoding, directoryPath);
|
||||
|
||||
TrangaSettings? settings = null;
|
||||
string[]? downloadLocationPath = GetArg(args, ArgEnum.DownloadLocation);
|
||||
@ -109,7 +109,7 @@ public partial class Tranga : GlobalBase
|
||||
{ ArgEnum.WorkingDirectory, new(new []{"-w", "--workingDirectory"}, 1, "Directory in which application-data is saved") },
|
||||
{ ArgEnum.ConsoleLogger, new(new []{"-c", "--consoleLogger"}, 0, "Enables the consoleLogger") },
|
||||
{ ArgEnum.FileLogger, new(new []{"-f", "--fileLogger"}, 0, "Enables the fileLogger") },
|
||||
{ ArgEnum.FileLoggerPath, new (new []{"-l", "--fPath"}, 1, "LogFilePath" ) },
|
||||
{ ArgEnum.FileLoggerPath, new (new []{"-l", "--fPath"}, 1, "Log Folder Path" ) },
|
||||
{ ArgEnum.Help, new(new []{"-h", "--help"}, 0, "Print this") }
|
||||
//{ ArgEnum., new(new []{""}, 1, "") }
|
||||
};
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System.Net.Http.Headers;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using Newtonsoft.Json;
|
||||
using Tranga.LibraryConnectors;
|
||||
using Tranga.MangaConnectors;
|
||||
@ -13,14 +12,15 @@ public class TrangaSettings
|
||||
public string downloadLocation { get; private set; }
|
||||
public string workingDirectory { get; private set; }
|
||||
public int apiPortNumber { get; init; }
|
||||
public string userAgent { get; set; } = DefaultUserAgent;
|
||||
public string userAgent { get; private set; } = DefaultUserAgent;
|
||||
[JsonIgnore] public string settingsFilePath => Path.Join(workingDirectory, "settings.json");
|
||||
[JsonIgnore] public string libraryConnectorsFilePath => Path.Join(workingDirectory, "libraryConnectors.json");
|
||||
[JsonIgnore] public string notificationConnectorsFilePath => Path.Join(workingDirectory, "notificationConnectors.json");
|
||||
[JsonIgnore] public string jobsFolderPath => Path.Join(workingDirectory, "jobs");
|
||||
[JsonIgnore] public string coverImageCache => Path.Join(workingDirectory, "imageCache");
|
||||
[JsonIgnore] internal static readonly string DefaultUserAgent = $"Tranga ({Enum.GetName(Environment.OSVersion.Platform)}; {(Environment.Is64BitOperatingSystem ? "x64" : "")}) / 1.0";
|
||||
public ushort? version { get; set; } = 1;
|
||||
public ushort? version { get; } = 1;
|
||||
public bool aprilFoolsMode { get; private set; } = true;
|
||||
[JsonIgnore]internal static readonly Dictionary<RequestType, int> DefaultRequestLimits = new ()
|
||||
{
|
||||
{RequestType.MangaInfo, 250},
|
||||
@ -102,6 +102,12 @@ public class TrangaSettings
|
||||
})!;
|
||||
}
|
||||
|
||||
public void UpdateAprilFoolsMode(bool enabled)
|
||||
{
|
||||
this.aprilFoolsMode = enabled;
|
||||
ExportSettings();
|
||||
}
|
||||
|
||||
public void UpdateDownloadLocation(string newPath, bool moveFiles = true)
|
||||
{
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
|
Reference in New Issue
Block a user