Compare commits
6 Commits
38df54baff
...
c965bc38d1
Author | SHA1 | Date | |
---|---|---|---|
c965bc38d1 | |||
37266ea095 | |||
8caac538c9 | |||
7c7f711bb4 | |||
d78897eb74 | |||
438c11af4f |
@ -9,5 +9,6 @@
|
|||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Manganato/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=Manganato/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Mangasee/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=Mangasee/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Mangaworld/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=Mangaworld/@EntryIndexedValue">True</s:Boolean>
|
||||||
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=Ntfy/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Taskmanager/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=Taskmanager/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Tranga/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=Tranga/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
@ -14,8 +14,8 @@ public abstract class GlobalBase
|
|||||||
protected HashSet<NotificationConnector> notificationConnectors { get; init; }
|
protected HashSet<NotificationConnector> notificationConnectors { get; init; }
|
||||||
protected HashSet<LibraryConnector> libraryConnectors { get; init; }
|
protected HashSet<LibraryConnector> libraryConnectors { get; init; }
|
||||||
protected List<Manga> cachedPublications { get; init; }
|
protected List<Manga> cachedPublications { get; init; }
|
||||||
protected static readonly NumberFormatInfo numberFormatDecimalPoint = new (){ NumberDecimalSeparator = "." };
|
public static readonly NumberFormatInfo numberFormatDecimalPoint = new (){ NumberDecimalSeparator = "." };
|
||||||
protected static readonly Regex baseUrlRex = new(@"https?:\/\/[0-9A-z\.-]*");
|
protected static readonly Regex baseUrlRex = new(@"https?:\/\/[0-9A-z\.-]+(:[0-9]+)?");
|
||||||
|
|
||||||
protected GlobalBase(GlobalBase clone)
|
protected GlobalBase(GlobalBase clone)
|
||||||
{
|
{
|
||||||
|
@ -33,6 +33,7 @@ public class DownloadChapter : Job
|
|||||||
{
|
{
|
||||||
mangaConnector.CopyCoverFromCacheToDownloadLocation(chapter.parentManga);
|
mangaConnector.CopyCoverFromCacheToDownloadLocation(chapter.parentManga);
|
||||||
HttpStatusCode success = mangaConnector.DownloadChapter(chapter, this.progressToken);
|
HttpStatusCode success = mangaConnector.DownloadChapter(chapter, this.progressToken);
|
||||||
|
chapter.parentManga.UpdateLatestDownloadedChapter(chapter);
|
||||||
if (success == HttpStatusCode.OK)
|
if (success == HttpStatusCode.OK)
|
||||||
{
|
{
|
||||||
UpdateLibraries();
|
UpdateLibraries();
|
||||||
|
@ -37,12 +37,19 @@ public class Kavita : LibraryConnector
|
|||||||
RequestUri = new Uri($"{baseUrl}/api/Account/login"),
|
RequestUri = new Uri($"{baseUrl}/api/Account/login"),
|
||||||
Content = new StringContent($"{{\"username\":\"{username}\",\"password\":\"{password}\"}}", System.Text.Encoding.UTF8, "application/json")
|
Content = new StringContent($"{{\"username\":\"{username}\",\"password\":\"{password}\"}}", System.Text.Encoding.UTF8, "application/json")
|
||||||
};
|
};
|
||||||
|
try
|
||||||
HttpResponseMessage response = client.Send(requestMessage);
|
{
|
||||||
JsonObject? result = JsonSerializer.Deserialize<JsonObject>(response.Content.ReadAsStream());
|
HttpResponseMessage response = client.Send(requestMessage);
|
||||||
if (result is not null)
|
JsonObject? result = JsonSerializer.Deserialize<JsonObject>(response.Content.ReadAsStream());
|
||||||
return result["token"]!.GetValue<string>();
|
if (result is not null)
|
||||||
else throw new Exception("Did not receive token.");
|
return result["token"]!.GetValue<string>();
|
||||||
|
}
|
||||||
|
catch (HttpRequestException e)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Unable to retrieve token:\n\r{e}");
|
||||||
|
}
|
||||||
|
Console.WriteLine("Kavita: Did not receive token.");
|
||||||
|
throw new Exception("Kavita: Did not receive token.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void UpdateLibrary()
|
public override void UpdateLibrary()
|
||||||
|
@ -26,12 +26,14 @@ public struct Manga
|
|||||||
// ReSharper disable once MemberCanBePrivate.Global
|
// ReSharper disable once MemberCanBePrivate.Global
|
||||||
public int? year { get; }
|
public int? year { get; }
|
||||||
public string? originalLanguage { get; }
|
public string? originalLanguage { get; }
|
||||||
// ReSharper disable once MemberCanBePrivate.Global
|
// ReSharper disable twice MemberCanBePrivate.Global
|
||||||
public string status { get; }
|
public string status { get; }
|
||||||
public string folderName { get; private set; }
|
public string folderName { get; private set; }
|
||||||
public string publicationId { get; }
|
public string publicationId { get; }
|
||||||
public string internalId { get; }
|
public string internalId { get; }
|
||||||
public float ignoreChaptersBelow { get; set; }
|
public float ignoreChaptersBelow { get; set; }
|
||||||
|
public float latestChapterDownloaded { get; set; }
|
||||||
|
public float latestChapterAvailable { get; set; }
|
||||||
|
|
||||||
private static readonly Regex LegalCharacters = new (@"[A-Z]*[a-z]*[0-9]* *\.*-*,*'*\'*\)*\(*~*!*");
|
private static readonly Regex LegalCharacters = new (@"[A-Z]*[a-z]*[0-9]* *\.*-*,*'*\'*\)*\(*~*!*");
|
||||||
|
|
||||||
@ -56,6 +58,8 @@ public struct Manga
|
|||||||
string onlyLowerLetters = string.Concat(this.sortName.ToLower().Where(Char.IsLetter));
|
string onlyLowerLetters = string.Concat(this.sortName.ToLower().Where(Char.IsLetter));
|
||||||
this.internalId = Convert.ToBase64String(Encoding.ASCII.GetBytes($"{onlyLowerLetters}{this.year}"));
|
this.internalId = Convert.ToBase64String(Encoding.ASCII.GetBytes($"{onlyLowerLetters}{this.year}"));
|
||||||
this.ignoreChaptersBelow = ignoreChaptersBelow ?? 0f;
|
this.ignoreChaptersBelow = ignoreChaptersBelow ?? 0f;
|
||||||
|
this.latestChapterDownloaded = 0;
|
||||||
|
this.latestChapterAvailable = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
@ -82,6 +86,12 @@ public struct Manga
|
|||||||
Directory.Move(oldPath, newPath);
|
Directory.Move(oldPath, newPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UpdateLatestDownloadedChapter(Chapter chapter)//TODO check files if chapters are all downloaded
|
||||||
|
{
|
||||||
|
float chapterNumber = Convert.ToSingle(chapter.chapterNumber, GlobalBase.numberFormatDecimalPoint);
|
||||||
|
latestChapterDownloaded = latestChapterDownloaded < chapterNumber ? chapterNumber : latestChapterDownloaded;
|
||||||
|
}
|
||||||
|
|
||||||
public void SaveSeriesInfoJson(string downloadDirectory)
|
public void SaveSeriesInfoJson(string downloadDirectory)
|
||||||
{
|
{
|
||||||
string publicationFolder = CreatePublicationFolder(downloadDirectory);
|
string publicationFolder = CreatePublicationFolder(downloadDirectory);
|
||||||
|
@ -56,12 +56,15 @@ public abstract class MangaConnector : GlobalBase
|
|||||||
public Chapter[] GetNewChapters(Manga manga, string language = "en")
|
public Chapter[] GetNewChapters(Manga manga, string language = "en")
|
||||||
{
|
{
|
||||||
Log($"Getting new Chapters for {manga}");
|
Log($"Getting new Chapters for {manga}");
|
||||||
Chapter[] newChapters = this.GetChapters(manga, language);
|
Chapter[] allChapters = this.GetChapters(manga, language);
|
||||||
Log($"Checking for duplicates {manga}");
|
Log($"Checking for duplicates {manga}");
|
||||||
List<Chapter> newChaptersList = newChapters.Where(nChapter => float.TryParse(nChapter.chapterNumber, numberFormatDecimalPoint, out float chapterNumber)
|
List<Chapter> newChaptersList = allChapters.Where(nChapter => float.TryParse(nChapter.chapterNumber, numberFormatDecimalPoint, out float chapterNumber)
|
||||||
&& chapterNumber > manga.ignoreChaptersBelow
|
&& chapterNumber > manga.ignoreChaptersBelow
|
||||||
&& !nChapter.CheckChapterIsDownloaded(settings.downloadLocation)).ToList();
|
&& !nChapter.CheckChapterIsDownloaded(settings.downloadLocation)).ToList();
|
||||||
Log($"{newChaptersList.Count} new chapters. {manga}");
|
Log($"{newChaptersList.Count} new chapters. {manga}");
|
||||||
|
Chapter latestChapterAvailable =
|
||||||
|
allChapters.MaxBy(chapter => Convert.ToSingle(chapter.chapterNumber, numberFormatDecimalPoint));
|
||||||
|
manga.latestChapterAvailable = Convert.ToSingle(latestChapterAvailable.chapterNumber, numberFormatDecimalPoint);
|
||||||
|
|
||||||
return newChaptersList.ToArray();
|
return newChaptersList.ToArray();
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ public abstract class NotificationConnector : GlobalBase
|
|||||||
this.notificationConnectorType = notificationConnectorType;
|
this.notificationConnectorType = notificationConnectorType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum NotificationConnectorType : byte { Gotify = 0, LunaSea = 1 }
|
public enum NotificationConnectorType : byte { Gotify = 0, LunaSea = 1, Ntfy = 2 }
|
||||||
|
|
||||||
public abstract void SendNotification(string title, string notificationText);
|
public abstract void SendNotification(string title, string notificationText);
|
||||||
}
|
}
|
@ -21,11 +21,15 @@ public class NotificationManagerJsonConverter : JsonConverter
|
|||||||
JsonSerializer serializer)
|
JsonSerializer serializer)
|
||||||
{
|
{
|
||||||
JObject jo = JObject.Load(reader);
|
JObject jo = JObject.Load(reader);
|
||||||
if (jo["notificationConnectorType"]!.Value<byte>() == (byte)NotificationConnector.NotificationConnectorType.Gotify)
|
switch (jo["notificationConnectorType"]!.Value<byte>())
|
||||||
return new Gotify(this._clone, jo.GetValue("endpoint")!.Value<string>()!, jo.GetValue("appToken")!.Value<string>()!);
|
{
|
||||||
else if (jo["notificationConnectorType"]!.Value<byte>() ==
|
case (byte)NotificationConnector.NotificationConnectorType.Gotify:
|
||||||
(byte)NotificationConnector.NotificationConnectorType.LunaSea)
|
return new Gotify(this._clone, jo.GetValue("endpoint")!.Value<string>()!, jo.GetValue("appToken")!.Value<string>()!);
|
||||||
return new LunaSea(this._clone, jo.GetValue("id")!.Value<string>()!);
|
case (byte)NotificationConnector.NotificationConnectorType.LunaSea:
|
||||||
|
return new LunaSea(this._clone, jo.GetValue("id")!.Value<string>()!);
|
||||||
|
case (byte)NotificationConnector.NotificationConnectorType.Ntfy:
|
||||||
|
return new Ntfy(this._clone, jo.GetValue("endpoint")!.Value<string>()!, jo.GetValue("auth")!.Value<string>()!);
|
||||||
|
}
|
||||||
|
|
||||||
throw new Exception();
|
throw new Exception();
|
||||||
}
|
}
|
||||||
|
58
Tranga/NotificationConnectors/Ntfy.cs
Normal file
58
Tranga/NotificationConnectors/Ntfy.cs
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
using System.Text;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace Tranga.NotificationConnectors;
|
||||||
|
|
||||||
|
public class Ntfy : NotificationConnector
|
||||||
|
{
|
||||||
|
// ReSharper disable once MemberCanBePrivate.Global
|
||||||
|
public string endpoint { get; init; }
|
||||||
|
private string auth { get; init; }
|
||||||
|
private const string Topic = "tranga";
|
||||||
|
private readonly HttpClient _client = new();
|
||||||
|
|
||||||
|
[JsonConstructor]
|
||||||
|
public Ntfy(GlobalBase clone, string endpoint, string auth) : base(clone, NotificationConnectorType.Ntfy)
|
||||||
|
{
|
||||||
|
if (!baseUrlRex.IsMatch(endpoint))
|
||||||
|
throw new ArgumentException("endpoint does not match pattern");
|
||||||
|
this.endpoint = endpoint;
|
||||||
|
this.auth = auth;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return $"Ntfy {endpoint} {Topic}";
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void SendNotification(string title, string notificationText)
|
||||||
|
{
|
||||||
|
Log($"Sending notification: {title} - {notificationText}");
|
||||||
|
MessageData message = new(title, notificationText);
|
||||||
|
HttpRequestMessage request = new(HttpMethod.Post, $"{this.endpoint}?auth={this.auth}");
|
||||||
|
request.Content = new StringContent(JsonConvert.SerializeObject(message, Formatting.None), Encoding.UTF8, "application/json");
|
||||||
|
HttpResponseMessage response = _client.Send(request);
|
||||||
|
if (!response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
StreamReader sr = new (response.Content.ReadAsStream());
|
||||||
|
Log($"{response.StatusCode}: {sr.ReadToEnd()}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class MessageData
|
||||||
|
{
|
||||||
|
// ReSharper disable UnusedAutoPropertyAccessor.Local
|
||||||
|
public string topic { get; }
|
||||||
|
public string title { get; }
|
||||||
|
public string message { get; }
|
||||||
|
public int priority { get; }
|
||||||
|
|
||||||
|
public MessageData(string title, string message)
|
||||||
|
{
|
||||||
|
this.topic = Topic;
|
||||||
|
this.title = title;
|
||||||
|
this.message = message;
|
||||||
|
this.priority = 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -335,6 +335,18 @@ public class Server : GlobalBase
|
|||||||
settings.UpdateDownloadLocation(downloadLocation, moveFiles);
|
settings.UpdateDownloadLocation(downloadLocation, moveFiles);
|
||||||
SendResponse(HttpStatusCode.Accepted, response);
|
SendResponse(HttpStatusCode.Accepted, response);
|
||||||
break;
|
break;
|
||||||
|
case "Settings/ChangeStyleSheet":
|
||||||
|
if (!requestVariables.TryGetValue("styleSheet", out string? styleSheet))
|
||||||
|
{
|
||||||
|
SendResponse(HttpStatusCode.BadRequest, response);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (settings.UpdateStyleSheet(styleSheet))
|
||||||
|
SendResponse(HttpStatusCode.Accepted, response);
|
||||||
|
else
|
||||||
|
SendResponse(HttpStatusCode.BadRequest, response, "Invalid parameter for styleSheet");
|
||||||
|
break;
|
||||||
/*case "Settings/UpdateWorkingDirectory":
|
/*case "Settings/UpdateWorkingDirectory":
|
||||||
if (!requestVariables.TryGetValue("workingDirectory", out string? workingDirectory))
|
if (!requestVariables.TryGetValue("workingDirectory", out string? workingDirectory))
|
||||||
{
|
{
|
||||||
@ -362,10 +374,7 @@ public class Server : GlobalBase
|
|||||||
}
|
}
|
||||||
AddNotificationConnector(new Gotify(this, gotifyUrl, gotifyAppToken));
|
AddNotificationConnector(new Gotify(this, gotifyUrl, gotifyAppToken));
|
||||||
SendResponse(HttpStatusCode.Accepted, response);
|
SendResponse(HttpStatusCode.Accepted, response);
|
||||||
break;
|
}else if (notificationConnectorType is NotificationConnector.NotificationConnectorType.LunaSea)
|
||||||
}
|
|
||||||
|
|
||||||
if (notificationConnectorType is NotificationConnector.NotificationConnectorType.LunaSea)
|
|
||||||
{
|
{
|
||||||
if (!requestVariables.TryGetValue("lunaseaWebhook", out string? lunaseaWebhook))
|
if (!requestVariables.TryGetValue("lunaseaWebhook", out string? lunaseaWebhook))
|
||||||
{
|
{
|
||||||
@ -374,13 +383,25 @@ public class Server : GlobalBase
|
|||||||
}
|
}
|
||||||
AddNotificationConnector(new LunaSea(this, lunaseaWebhook));
|
AddNotificationConnector(new LunaSea(this, lunaseaWebhook));
|
||||||
SendResponse(HttpStatusCode.Accepted, response);
|
SendResponse(HttpStatusCode.Accepted, response);
|
||||||
break;
|
}else if (notificationConnectorType is NotificationConnector.NotificationConnectorType.Ntfy)
|
||||||
|
{
|
||||||
|
if (!requestVariables.TryGetValue("ntfyUrl", out string? ntfyUrl) ||
|
||||||
|
!requestVariables.TryGetValue("ntfyAuth", out string? ntfyAuth))
|
||||||
|
{
|
||||||
|
SendResponse(HttpStatusCode.BadRequest, response);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
AddNotificationConnector(new Ntfy(this, ntfyUrl, ntfyAuth));
|
||||||
|
SendResponse(HttpStatusCode.Accepted, response);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SendResponse(HttpStatusCode.BadRequest, response);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "LibraryConnectors/Update":
|
case "LibraryConnectors/Update":
|
||||||
if (!requestVariables.TryGetValue("libraryConnector", out string? libraryConnectorStr) ||
|
if (!requestVariables.TryGetValue("libraryConnector", out string? libraryConnectorStr) ||
|
||||||
!Enum.TryParse(libraryConnectorStr,
|
!Enum.TryParse(libraryConnectorStr, out LibraryConnector.LibraryType libraryConnectorType))
|
||||||
out LibraryConnector.LibraryType libraryConnectorType))
|
|
||||||
{
|
{
|
||||||
SendResponse(HttpStatusCode.BadRequest, response);
|
SendResponse(HttpStatusCode.BadRequest, response);
|
||||||
break;
|
break;
|
||||||
@ -397,10 +418,7 @@ public class Server : GlobalBase
|
|||||||
}
|
}
|
||||||
AddLibraryConnector(new Kavita(this, kavitaUrl, kavitaUsername, kavitaPassword));
|
AddLibraryConnector(new Kavita(this, kavitaUrl, kavitaUsername, kavitaPassword));
|
||||||
SendResponse(HttpStatusCode.Accepted, response);
|
SendResponse(HttpStatusCode.Accepted, response);
|
||||||
break;
|
}else if (libraryConnectorType is LibraryConnector.LibraryType.Komga)
|
||||||
}
|
|
||||||
|
|
||||||
if (libraryConnectorType is LibraryConnector.LibraryType.Komga)
|
|
||||||
{
|
{
|
||||||
if (!requestVariables.TryGetValue("komgaUrl", out string? komgaUrl) ||
|
if (!requestVariables.TryGetValue("komgaUrl", out string? komgaUrl) ||
|
||||||
!requestVariables.TryGetValue("komgaAuth", out string? komgaAuth))
|
!requestVariables.TryGetValue("komgaAuth", out string? komgaAuth))
|
||||||
@ -410,7 +428,10 @@ public class Server : GlobalBase
|
|||||||
}
|
}
|
||||||
AddLibraryConnector(new Komga(this, komgaUrl, komgaAuth));
|
AddLibraryConnector(new Komga(this, komgaUrl, komgaAuth));
|
||||||
SendResponse(HttpStatusCode.Accepted, response);
|
SendResponse(HttpStatusCode.Accepted, response);
|
||||||
break;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SendResponse(HttpStatusCode.BadRequest, response);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "LogMessages":
|
case "LogMessages":
|
||||||
|
@ -11,6 +11,7 @@ public class TrangaSettings
|
|||||||
public string downloadLocation { get; private set; }
|
public string downloadLocation { get; private set; }
|
||||||
public string workingDirectory { get; private set; }
|
public string workingDirectory { get; private set; }
|
||||||
public int apiPortNumber { get; init; }
|
public int apiPortNumber { get; init; }
|
||||||
|
public string styleSheet { get; private set; }
|
||||||
[JsonIgnore] public string settingsFilePath => Path.Join(workingDirectory, "settings.json");
|
[JsonIgnore] public string settingsFilePath => Path.Join(workingDirectory, "settings.json");
|
||||||
[JsonIgnore] public string libraryConnectorsFilePath => Path.Join(workingDirectory, "libraryConnectors.json");
|
[JsonIgnore] public string libraryConnectorsFilePath => Path.Join(workingDirectory, "libraryConnectors.json");
|
||||||
[JsonIgnore] public string notificationConnectorsFilePath => Path.Join(workingDirectory, "notificationConnectors.json");
|
[JsonIgnore] public string notificationConnectorsFilePath => Path.Join(workingDirectory, "notificationConnectors.json");
|
||||||
@ -29,6 +30,7 @@ public class TrangaSettings
|
|||||||
this.downloadLocation = downloadLocation ?? settings.downloadLocation;
|
this.downloadLocation = downloadLocation ?? settings.downloadLocation;
|
||||||
this.workingDirectory = workingDirectory ?? settings.workingDirectory;
|
this.workingDirectory = workingDirectory ?? settings.workingDirectory;
|
||||||
this.apiPortNumber = apiPortNumber ?? settings.apiPortNumber;
|
this.apiPortNumber = apiPortNumber ?? settings.apiPortNumber;
|
||||||
|
this.styleSheet = "default" ?? settings.styleSheet;
|
||||||
lockFile.Close(); //unlock settingsfile
|
lockFile.Close(); //unlock settingsfile
|
||||||
}
|
}
|
||||||
else if(!File.Exists(settingsFilePath))
|
else if(!File.Exists(settingsFilePath))
|
||||||
@ -38,6 +40,7 @@ public class TrangaSettings
|
|||||||
this.apiPortNumber = apiPortNumber ?? 6531;
|
this.apiPortNumber = apiPortNumber ?? 6531;
|
||||||
this.downloadLocation = downloadLocation ?? (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? "/Manga" : Path.Join(Directory.GetCurrentDirectory(), "Downloads"));
|
this.downloadLocation = downloadLocation ?? (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? "/Manga" : Path.Join(Directory.GetCurrentDirectory(), "Downloads"));
|
||||||
this.workingDirectory = workingDirectory ?? Path.Join(RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? "/usr/share" : Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "tranga-api");
|
this.workingDirectory = workingDirectory ?? Path.Join(RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? "/usr/share" : Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "tranga-api");
|
||||||
|
this.styleSheet = "default";
|
||||||
ExportSettings();
|
ExportSettings();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -45,6 +48,7 @@ public class TrangaSettings
|
|||||||
this.apiPortNumber = apiPortNumber!.Value;
|
this.apiPortNumber = apiPortNumber!.Value;
|
||||||
this.downloadLocation = downloadLocation!;
|
this.downloadLocation = downloadLocation!;
|
||||||
this.workingDirectory = workingDirectory!;
|
this.workingDirectory = workingDirectory!;
|
||||||
|
this.styleSheet = "default";
|
||||||
}
|
}
|
||||||
UpdateDownloadLocation(this.downloadLocation, false);
|
UpdateDownloadLocation(this.downloadLocation, false);
|
||||||
}
|
}
|
||||||
@ -77,6 +81,17 @@ public class TrangaSettings
|
|||||||
})!;
|
})!;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool UpdateStyleSheet(string newStyleSheet)
|
||||||
|
{
|
||||||
|
string[] validStyleSheets = { "default", "hover" };
|
||||||
|
if (validStyleSheets.Contains(newStyleSheet))
|
||||||
|
{
|
||||||
|
this.styleSheet = newStyleSheet;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public void UpdateDownloadLocation(string newPath, bool moveFiles = true)
|
public void UpdateDownloadLocation(string newPath, bool moveFiles = true)
|
||||||
{
|
{
|
||||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||||
|
Loading…
Reference in New Issue
Block a user