Merge remote-tracking branch 'upstream/cuttingedge' into json-api
This commit is contained in:
commit
2768ab38e6
@ -111,7 +111,7 @@ public class MangaDex : MangaConnector
|
|||||||
string description = descriptionNode!.AsObject().ContainsKey("en") switch
|
string description = descriptionNode!.AsObject().ContainsKey("en") switch
|
||||||
{
|
{
|
||||||
true => descriptionNode.AsObject()["en"]!.GetValue<string>(),
|
true => descriptionNode.AsObject()["en"]!.GetValue<string>(),
|
||||||
false => descriptionNode.AsObject().First().Value!.GetValue<string>()
|
false => descriptionNode.AsObject().FirstOrDefault().Value?.GetValue<string>() ?? ""
|
||||||
};
|
};
|
||||||
|
|
||||||
Dictionary<string, string> linksDict = new();
|
Dictionary<string, string> linksDict = new();
|
||||||
@ -122,14 +122,14 @@ public class MangaDex : MangaConnector
|
|||||||
string? originalLanguage =
|
string? originalLanguage =
|
||||||
attributes.TryGetPropertyValue("originalLanguage", out JsonNode? originalLanguageNode) switch
|
attributes.TryGetPropertyValue("originalLanguage", out JsonNode? originalLanguageNode) switch
|
||||||
{
|
{
|
||||||
true => originalLanguageNode!.GetValue<string>(),
|
true => originalLanguageNode?.GetValue<string>(),
|
||||||
false => null
|
false => null
|
||||||
};
|
};
|
||||||
|
|
||||||
Manga.ReleaseStatusByte status = Manga.ReleaseStatusByte.Unreleased;
|
Manga.ReleaseStatusByte status = Manga.ReleaseStatusByte.Unreleased;
|
||||||
if (attributes.TryGetPropertyValue("status", out JsonNode? statusNode))
|
if (attributes.TryGetPropertyValue("status", out JsonNode? statusNode))
|
||||||
{
|
{
|
||||||
status = statusNode!.GetValue<string>().ToLower() switch
|
status = statusNode?.GetValue<string>().ToLower() switch
|
||||||
{
|
{
|
||||||
"ongoing" => Manga.ReleaseStatusByte.Continuing,
|
"ongoing" => Manga.ReleaseStatusByte.Continuing,
|
||||||
"completed" => Manga.ReleaseStatusByte.Completed,
|
"completed" => Manga.ReleaseStatusByte.Completed,
|
||||||
@ -141,7 +141,7 @@ public class MangaDex : MangaConnector
|
|||||||
|
|
||||||
int? year = attributes.TryGetPropertyValue("year", out JsonNode? yearNode) switch
|
int? year = attributes.TryGetPropertyValue("year", out JsonNode? yearNode) switch
|
||||||
{
|
{
|
||||||
true => yearNode!.GetValue<int>(),
|
true => yearNode?.GetValue<int>(),
|
||||||
false => null
|
false => null
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@ public enum RequestType : byte
|
|||||||
MangaDexFeed = 1,
|
MangaDexFeed = 1,
|
||||||
MangaImage = 2,
|
MangaImage = 2,
|
||||||
MangaCover = 3,
|
MangaCover = 3,
|
||||||
MangaDexAuthor = 4,
|
|
||||||
MangaDexImage = 5,
|
MangaDexImage = 5,
|
||||||
MangaInfo = 6
|
MangaInfo = 6
|
||||||
}
|
}
|
@ -1,4 +1,6 @@
|
|||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text.Json.Nodes;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Tranga.LibraryConnectors;
|
using Tranga.LibraryConnectors;
|
||||||
using Tranga.MangaConnectors;
|
using Tranga.MangaConnectors;
|
||||||
@ -19,7 +21,7 @@ public class TrangaSettings
|
|||||||
[JsonIgnore] public string jobsFolderPath => Path.Join(workingDirectory, "jobs");
|
[JsonIgnore] public string jobsFolderPath => Path.Join(workingDirectory, "jobs");
|
||||||
[JsonIgnore] public string coverImageCache => Path.Join(workingDirectory, "imageCache");
|
[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";
|
[JsonIgnore] internal static readonly string DefaultUserAgent = $"Tranga ({Enum.GetName(Environment.OSVersion.Platform)}; {(Environment.Is64BitOperatingSystem ? "x64" : "")}) / 1.0";
|
||||||
public ushort? version { get; } = 1;
|
public ushort? version { get; } = 2;
|
||||||
public bool aprilFoolsMode { get; private set; } = true;
|
public bool aprilFoolsMode { get; private set; } = true;
|
||||||
[JsonIgnore]internal static readonly Dictionary<RequestType, int> DefaultRequestLimits = new ()
|
[JsonIgnore]internal static readonly Dictionary<RequestType, int> DefaultRequestLimits = new ()
|
||||||
{
|
{
|
||||||
@ -28,7 +30,6 @@ public class TrangaSettings
|
|||||||
{RequestType.MangaDexImage, 40},
|
{RequestType.MangaDexImage, 40},
|
||||||
{RequestType.MangaImage, 60},
|
{RequestType.MangaImage, 60},
|
||||||
{RequestType.MangaCover, 250},
|
{RequestType.MangaCover, 250},
|
||||||
{RequestType.MangaDexAuthor, 250},
|
|
||||||
{RequestType.Default, 60}
|
{RequestType.Default, 60}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -44,6 +45,7 @@ public class TrangaSettings
|
|||||||
{//Load from settings file
|
{//Load from settings file
|
||||||
FileStream lockFile = File.Create(lockFilePath,0, FileOptions.DeleteOnClose); //lock settingsfile
|
FileStream lockFile = File.Create(lockFilePath,0, FileOptions.DeleteOnClose); //lock settingsfile
|
||||||
string settingsStr = File.ReadAllText(sfp);
|
string settingsStr = File.ReadAllText(sfp);
|
||||||
|
settingsStr = Regex.Replace(settingsStr, @"""MangaDexAuthor"": [0-9]+,", "");//https://github.com/C9Glax/tranga/pull/161 Remove sometime in the future :3
|
||||||
TrangaSettings settings = JsonConvert.DeserializeObject<TrangaSettings>(settingsStr)!;
|
TrangaSettings settings = JsonConvert.DeserializeObject<TrangaSettings>(settingsStr)!;
|
||||||
this.requestLimits = settings.requestLimits;
|
this.requestLimits = settings.requestLimits;
|
||||||
this.userAgent = settings.userAgent;
|
this.userAgent = settings.userAgent;
|
||||||
|
Loading…
Reference in New Issue
Block a user