Fix E621Tags
This commit is contained in:
@@ -3,8 +3,8 @@
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
<AssemblyVersion>2020.3.29.0</AssemblyVersion>
|
||||
<FileVersion>2020.3.29.0</FileVersion>
|
||||
<AssemblyVersion>2020.4.10.0</AssemblyVersion>
|
||||
<FileVersion>2020.4.10.0</FileVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -21,43 +21,61 @@ namespace Booru.Net.Tests
|
||||
{
|
||||
try
|
||||
{
|
||||
IEnumerable<BooruImage> posts = null;
|
||||
|
||||
Console.WriteLine(client);
|
||||
|
||||
switch(client)
|
||||
string[] tags = new[] { "corona" };
|
||||
|
||||
switch (client)
|
||||
{
|
||||
case 0:
|
||||
posts = await new DanbooruClient().GetImagesAsync().ConfigureAwait(false);
|
||||
{
|
||||
var posts = await new DanbooruClient().GetImagesAsync(tags).ConfigureAwait(false);
|
||||
Console.WriteLine(posts.Any(x => x.Tags.Any(z=>tags.Contains(z) != null)));
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
var p = await new E621Client().GetImagesAsync().ConfigureAwait(false);
|
||||
Console.WriteLine(p.Posts.Any(x => x.ImageUrl != null));
|
||||
{
|
||||
var p = await new E621Client().GetImagesAsync(tags).ConfigureAwait(false);
|
||||
Console.WriteLine(p.Posts.All(x => x.Tags.Any(z => z.Value.Any(y => tags.Contains(y)))));
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
posts = await new GelbooruClient().GetImagesAsync().ConfigureAwait(false);
|
||||
{
|
||||
var posts = await new GelbooruClient().GetImagesAsync(tags).ConfigureAwait(false);
|
||||
Console.WriteLine(posts.Any(x => x.Tags.Any(z => tags.Contains(z) != null)));
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
posts = await new KonaChanClient().GetImagesAsync().ConfigureAwait(false);
|
||||
{
|
||||
var posts = await new KonaChanClient().GetImagesAsync(tags).ConfigureAwait(false);
|
||||
Console.WriteLine(posts.Any(x => x.Tags.Any(z => tags.Contains(z) != null)));
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
posts = await new RealbooruClient().GetImagesAsync().ConfigureAwait(false);
|
||||
{
|
||||
var posts = await new RealbooruClient().GetImagesAsync(tags).ConfigureAwait(false);
|
||||
Console.WriteLine(posts.Any(x => x.Tags.Any(z => tags.Contains(z) != null)));
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
posts = await new Rule34Client().GetImagesAsync().ConfigureAwait(false);
|
||||
{
|
||||
var posts = await new Rule34Client().GetImagesAsync(tags).ConfigureAwait(false);
|
||||
Console.WriteLine(posts.Any(x => x.Tags.Any(z => tags.Contains(z) != null)));
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
posts = await new SafebooruClient().GetImagesAsync().ConfigureAwait(false);
|
||||
{
|
||||
var posts = await new SafebooruClient().GetImagesAsync(tags).ConfigureAwait(false);
|
||||
Console.WriteLine(posts.Any(x => x.Tags.Any(z => tags.Contains(z) != null)));
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
posts = await new YandereClient().GetImagesAsync().ConfigureAwait(false);
|
||||
{
|
||||
var posts = await new YandereClient().GetImagesAsync(tags).ConfigureAwait(false);
|
||||
Console.WriteLine(posts.Any(x => x.Tags.Any(z => tags.Contains(z) != null)));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (posts != null)
|
||||
{
|
||||
Console.WriteLine(posts.Any(x => x.ImageUrl != null));
|
||||
}
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
|
||||
@@ -26,8 +26,8 @@ Yande.re</Description>
|
||||
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
|
||||
<Version>2.0.3</Version>
|
||||
<PackageLicenseFile>LICENSE</PackageLicenseFile>
|
||||
<AssemblyVersion>2020.3.0.0</AssemblyVersion>
|
||||
<FileVersion>2020.3.0.0</FileVersion>
|
||||
<AssemblyVersion>2020.4.9.0</AssemblyVersion>
|
||||
<FileVersion>2020.4.9.0</FileVersion>
|
||||
<PackageReleaseNotes>Fix some null ref issues with images</PackageReleaseNotes>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Booru.Net.Converters
|
||||
{
|
||||
@@ -16,25 +17,11 @@ namespace Booru.Net.Converters
|
||||
{
|
||||
var token = JToken.Load(reader);
|
||||
|
||||
List<Dictionary<string, List<string>>> container = new List<Dictionary<string, List<string>>>();
|
||||
Dictionary<string, List<string>> container = new Dictionary<string, List<string>>();
|
||||
|
||||
foreach(var el in token.Children<JObject>())
|
||||
foreach(JProperty el in token.Values<JProperty>())
|
||||
{
|
||||
Dictionary<string, List<string>> att = new Dictionary<string, List<string>>();
|
||||
foreach (JProperty prop in el.Properties())
|
||||
{
|
||||
List<string> children = new List<string>();
|
||||
|
||||
foreach(var child in prop.Value.Children())
|
||||
{
|
||||
children.Add(child.Value<string>());
|
||||
}
|
||||
|
||||
att.Add(prop.Name, children);
|
||||
break;
|
||||
}
|
||||
|
||||
container.Add(att);
|
||||
container.Add(el.Name, el.Value.Values<string>().ToList());
|
||||
}
|
||||
|
||||
return container;
|
||||
|
||||
@@ -26,9 +26,9 @@ namespace Booru.Net
|
||||
|
||||
[JsonProperty("tags")]
|
||||
[JsonConverter(typeof(TagGroupConverter))]
|
||||
private List<Dictionary<string, List<string>>> PTags { get; set; }
|
||||
private Dictionary<string, List<string>> PTags { get; set; }
|
||||
|
||||
public IReadOnlyList<Dictionary<string, List<string>>> Tags { get { return PTags.AsReadOnly(); } }
|
||||
public IReadOnlyDictionary<string, List<string>> Tags { get { return PTags; } }
|
||||
|
||||
public override string ImageUrl => File.Url;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user