diff --git a/Gallery.Util/Converter.cs b/Gallery.Util/Converter.cs index b3fee07..2c8bd0b 100644 --- a/Gallery.Util/Converter.cs +++ b/Gallery.Util/Converter.cs @@ -10,7 +10,6 @@ namespace Gallery.Util { public override GalleryItem Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - reader.Read(); if (reader.TokenType != JsonTokenType.StartObject) { return null; @@ -18,6 +17,10 @@ namespace Gallery.Util var item = new GalleryItem(); while (reader.Read()) { + if (reader.TokenType == JsonTokenType.EndObject) + { + return item; + } if (reader.TokenType == JsonTokenType.PropertyName) { var name = reader.GetString(); @@ -55,7 +58,7 @@ namespace Gallery.Util } } } - return item; + throw new ArgumentOutOfRangeException(); } public override void Write(Utf8JsonWriter writer, GalleryItem value, JsonSerializerOptions options) diff --git a/GallerySources/Gallery.Danbooru/GallerySource.cs b/GallerySources/Gallery.Danbooru/GallerySource.cs index a8a7512..23135df 100644 --- a/GallerySources/Gallery.Danbooru/GallerySource.cs +++ b/GallerySources/Gallery.Danbooru/GallerySource.cs @@ -38,7 +38,7 @@ namespace Gallery.Danbooru { var g = matches[i].Groups; var tags = g[2].Value.Replace(" ", "\",\""); - array[i] = $"{{\"Id\":{g[0].Value},\"Tags\":[\"{tags}\"]}}"; + array[i] = $"{{\"Id\":{g[1].Value},\"Tags\":[\"{tags}\"],\"Width\":{g[3].Value},\"Height\":{g[4].Value},\"Source\":\"{g[7].Value}\",\"UserId\":\"{g[6].Value}\",\"RawUrl\":\"{g[8].Value}\",\"PreviewUrl\":\"{g[9].Value}\"}}"; } return $"[{string.Join(',', array)}]"; }