Xwilarg / BooruSharp

A C# library to browse Booru websites (Gelbooru, Konachan, E621...) easily
https://boorusharp.zirk.eu
MIT License
75 stars 7 forks source link

Safebooru doesn't appear to be working for me #52

Open catgirlkara opened 2 months ago

catgirlkara commented 2 months ago

var booru = new BooruSharp.Booru.Safebooru(); PostSearchResult? result = null; try { result = await booru.GetRandomPostAsync(); } catch (Exception e) { Console.WriteLine(e); }

Throws this exception:

System.Text.Json.JsonException: The JSON value could not be converted to System.String. Path: $[0].directory | LineNumber: 0 | BytePositionInLine: 336. ---> System.InvalidOperationException: Cannot get the value of a token type 'Number' as a string. at System.Text.Json.ThrowHelper.ThrowInvalidOperationException_ExpectedString(JsonTokenType tokenType) at System.Text.Json.Utf8JsonReader.GetString() at System.Text.Json.Serialization.Metadata.JsonPropertyInfo1.ReadJsonAndSetMember(Object obj, ReadStack& state, Utf8JsonReader& reader) at System.Text.Json.Serialization.Converters.ObjectDefaultConverter1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value) at System.Text.Json.Serialization.JsonConverter1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue) at System.Text.Json.Serialization.JsonCollectionConverter2.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, TCollection& value) at System.Text.Json.Serialization.JsonConverter1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue) at System.Text.Json.Serialization.JsonConverter1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state) --- End of inner exception stack trace --- at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, Utf8JsonReader& reader, Exception ex) at System.Text.Json.Serialization.JsonConverter1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state) at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan1 utf8Json, JsonTypeInfo1 jsonTypeInfo, Nullable1 actualByteCount) at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan1 json, JsonTypeInfo1 jsonTypeInfo) at System.Text.Json.JsonSerializer.Deserialize[TValue](String json, JsonSerializerOptions options) at BooruSharp.Booru.ABooru.GetDataAsync[T](Uri url) at BooruSharp.Booru.Template.Gelbooru02.GetPostSearchResultAsync(Uri uri) at BooruSharp.Booru.ABooru.GetRandomPostAsync(String[] tagsArg)

catgirlkara commented 2 months ago

Also just wanted to say that your API is amazing and easy to use! Thanks <3

Xwilarg commented 2 months ago

Hey, thanks for the bug report, could you please tell me which version of the library you are using?

catgirlkara commented 2 months ago

i pulled the latest i could find on nuget. looks like 4.0.0-beta?

catgirlkara commented 2 months ago

I rolled back to 3.6.0 and Safebooru works! TY

Xwilarg commented 2 months ago

Good to know, I'll still have a look at beta to see if I can do something, thanks