MangaDex fix crash if "en" tag was missing

This commit is contained in:
Glax 2025-05-17 22:51:57 +02:00
parent 703e32a30e
commit 63442e9af6

View File

@ -228,8 +228,8 @@ public class MangaDex : MangaConnector
string? id = jToken.Value<string>("id");
JObject? attributes = jToken["attributes"] as JObject;
string? name = attributes?["title"]?.Value<string>("en");
string? description = attributes?["description"]?.Value<string>("en");
string? name = attributes?["title"]?.Value<string>("en")??attributes?["title"]?.First?.Value<string>();
string? description = attributes?["description"]?.Value<string>("en")??attributes?["description"]?.First?.Value<string>();
string? status = attributes?["status"]?.Value<string>();
uint? year = attributes?["year"]?.Value<uint>();
string? originalLanguage = attributes?["originalLanguage"]?.Value<string>();
@ -288,7 +288,7 @@ public class MangaDex : MangaConnector
List<MangaTag> tags = tagsJArray
.Where(t => t.Value<string>("type") == "tag")
.Select(t => t["attributes"]?["name"]?.Value<string>("en"))
.Select(t => t["attributes"]?["name"]?.Value<string>("en")??t["attributes"]?["name"]?.First?.Value<string>())
.Select(str => str is not null ? new MangaTag(str) : null)
.Where(x => x is not null).ToList()!;