danbooru source

This commit is contained in:
Tsanie 2021-08-10 17:33:51 +08:00
parent 6507f7cadf
commit 8f8cfaca54
2 changed files with 6 additions and 3 deletions

View File

@ -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)

View File

@ -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)}]";
}