MangaDex fix crash if "en" tag was missing

This commit is contained in:
Glax 2025-05-17 23:05:48 +02:00
parent 63442e9af6
commit fe60b98cb8

View File

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