mirror of
https://github.com/C9Glax/tranga.git
synced 2025-02-23 07:40:13 +01:00
null checks
This commit is contained in:
parent
8631cf6376
commit
c67e89f1dd
@ -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
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user