Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e8a1391a38 | |||
| 8492bc994e | |||
| c1e7e93ed7 | |||
| ed236340cd | |||
| f2d21dc411 | |||
| 7266a2162d | |||
| 4e6b8b2de8 | |||
| f12f9d70a0 |
@@ -3,8 +3,8 @@
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
<AssemblyVersion>2020.3.24.0</AssemblyVersion>
|
||||
<FileVersion>2020.3.24.0</FileVersion>
|
||||
<AssemblyVersion>2020.4.10.0</AssemblyVersion>
|
||||
<FileVersion>2020.4.10.0</FileVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -21,42 +21,60 @@ 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.All(x => x != 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);
|
||||
break;
|
||||
}
|
||||
|
||||
if (posts != null)
|
||||
{
|
||||
Console.WriteLine(posts.All(x => x != null));
|
||||
var posts = await new YandereClient().GetImagesAsync(tags).ConfigureAwait(false);
|
||||
Console.WriteLine(posts.Any(x => x.Tags.Any(z => tags.Contains(z) != null)));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch(Exception ex)
|
||||
|
||||
@@ -24,14 +24,11 @@ Yande.re</Description>
|
||||
<PackageTags>booru imageboard api wrapper</PackageTags>
|
||||
<PackageLicenseUrl></PackageLicenseUrl>
|
||||
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
|
||||
<Version>2.0.0.0</Version>
|
||||
<Version>2.0.4</Version>
|
||||
<PackageLicenseFile>LICENSE</PackageLicenseFile>
|
||||
<AssemblyVersion>2.0.0.0</AssemblyVersion>
|
||||
<FileVersion>2.0.0.0</FileVersion>
|
||||
<PackageReleaseNotes>⚠ This version is not compatible with 1.0.0.X code ⚠
|
||||
|
||||
Wrapper Restructuring & Seperate out each client from the container client
|
||||
Fix bugs presented from some booru's updating</PackageReleaseNotes>
|
||||
<AssemblyVersion>2.0.4.0</AssemblyVersion>
|
||||
<FileVersion>2.0.4.0</FileVersion>
|
||||
<PackageReleaseNotes>Fix E621 Tags</PackageReleaseNotes>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -5,6 +5,15 @@ namespace Booru.Net
|
||||
{
|
||||
public class DanbooruImage : BooruImage
|
||||
{
|
||||
[JsonProperty("score")]
|
||||
public int? Score { get; set; }
|
||||
|
||||
[JsonProperty("file_url")]
|
||||
private string FileUrl { get; set; }
|
||||
|
||||
public override string ImageUrl
|
||||
=> FileUrl;
|
||||
|
||||
[JsonProperty("tag_string")]
|
||||
private string TagString { get; set; }
|
||||
|
||||
|
||||
@@ -12,11 +12,25 @@ namespace Booru.Net
|
||||
[JsonProperty("directory")]
|
||||
public string Directory { get; set; }
|
||||
|
||||
[JsonProperty("file")]
|
||||
public E621ImageSource File { get; set; }
|
||||
|
||||
[JsonProperty("preview")]
|
||||
public E621ImageSource PreviewImage { get; set; }
|
||||
|
||||
[JsonProperty("sample")]
|
||||
public E621ImageSource SampleImage { get; set; }
|
||||
|
||||
[JsonProperty("flags")]
|
||||
public E621ImageFlags Flags { get; set; }
|
||||
|
||||
[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;
|
||||
|
||||
public override string PostUrl { get { return "https://e621.net/post/show/" + ID; } }
|
||||
}
|
||||
|
||||
25
Booru.Net/Models/Boards/E621ImageFlags.cs
Normal file
25
Booru.Net/Models/Boards/E621ImageFlags.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Booru.Net
|
||||
{
|
||||
public class E621ImageFlags
|
||||
{
|
||||
[JsonProperty("pending")]
|
||||
public bool Pending { get; private set; }
|
||||
|
||||
[JsonProperty("flagged")]
|
||||
public bool Flagged { get; private set; }
|
||||
|
||||
[JsonProperty("note_locked")]
|
||||
public bool NoteLocked { get; private set; }
|
||||
|
||||
[JsonProperty("status_locked")]
|
||||
public bool StatusLocked { get; private set; }
|
||||
|
||||
[JsonProperty("rating_locked")]
|
||||
public bool RatingLocked { get; private set; }
|
||||
|
||||
[JsonProperty("deleted")]
|
||||
public bool Deleted { get; private set; }
|
||||
}
|
||||
}
|
||||
28
Booru.Net/Models/Boards/E621ImageSource.cs
Normal file
28
Booru.Net/Models/Boards/E621ImageSource.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Booru.Net
|
||||
{
|
||||
public class E621ImageSource
|
||||
{
|
||||
[JsonProperty("width")]
|
||||
public int Width { get; private set; }
|
||||
|
||||
[JsonProperty("height")]
|
||||
public int Height { get; private set; }
|
||||
|
||||
[JsonProperty("ext")]
|
||||
public string Extension { get; private set; }
|
||||
|
||||
[JsonProperty("size")]
|
||||
public ulong Size { get; private set; }
|
||||
|
||||
[JsonProperty("has")]
|
||||
public bool Has { get; private set; }
|
||||
|
||||
[JsonProperty("md5")]
|
||||
public string MD5 { get; private set; }
|
||||
|
||||
[JsonProperty("url")]
|
||||
public string Url { get; private set; }
|
||||
}
|
||||
}
|
||||
@@ -8,9 +8,9 @@ namespace Booru.Net
|
||||
public int Up { get; set; }
|
||||
|
||||
[JsonProperty("down")]
|
||||
private int Down { get; set; }
|
||||
public int Down { get; set; }
|
||||
|
||||
[JsonProperty("total")]
|
||||
private int Total { get; set; }
|
||||
public int Total { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,12 @@ namespace Booru.Net
|
||||
[JsonProperty("directory")]
|
||||
public string Directory { get; set; }
|
||||
|
||||
[JsonProperty("file_url")]
|
||||
private string FileUrl { get; set; }
|
||||
|
||||
public override string ImageUrl
|
||||
=> FileUrl;
|
||||
|
||||
[JsonProperty("tags")]
|
||||
private string Ptags { get; set; }
|
||||
|
||||
|
||||
@@ -10,9 +10,9 @@ namespace Booru.Net
|
||||
[JsonProperty("rating")]
|
||||
private string Prating { get; set; }
|
||||
|
||||
public virtual string ImageUrl { get; set; }
|
||||
public virtual string ImageUrl { get; private set; }
|
||||
|
||||
public virtual string PostUrl { get; set; }
|
||||
public virtual string PostUrl { get; private set; }
|
||||
|
||||
public Rating Rating
|
||||
{
|
||||
|
||||
26
README.md
26
README.md
@@ -14,9 +14,22 @@ Currently supported Boards are:
|
||||
# How to get started
|
||||
|
||||
```cs
|
||||
var BooruClient = new BooruClient();
|
||||
var GelbooruClient = new GelbooruClient();
|
||||
|
||||
var posts = await BooruClient.GetGelbooruImagesAsync("aisha_clanclan", "melfina");
|
||||
var posts = await GelbooruClient.GetImagesAsync("aisha_clanclan", "melfina");
|
||||
|
||||
if(posts != null)
|
||||
{
|
||||
...
|
||||
}
|
||||
|
||||
List<string> tags = new List<string>
|
||||
{
|
||||
"aisha_clanclan",
|
||||
"melfina"
|
||||
};
|
||||
|
||||
posts = await GelbooruClient.GetImagesAsync(tags);
|
||||
|
||||
if(posts != null)
|
||||
{
|
||||
@@ -24,14 +37,5 @@ if(posts != null)
|
||||
}
|
||||
```
|
||||
|
||||
List of Methods in Wrapper:
|
||||
- `GetGelbooruImagesAsync(IEnumerable<string> tags)`
|
||||
- `GetDanbooruImagesAsync(IEnumerable<string> tags)`
|
||||
- `GetRule34ImagesAsync(IEnumerable<string> tags)`
|
||||
- `GetE621ImagesAsync(IEnumerable<string> tags)`
|
||||
- `GetKonaChanImagesAsync(IEnumerable<string> tags)`
|
||||
- `GetYandereImagesAsync(IEnumerable<string> tags)`
|
||||
- `GetRealBooruImagesAsync(IEnumerable<string> tags)`
|
||||
|
||||
# Contributing
|
||||
If you wish to add more booru's to the wrapper/make the code better/optimise the code, please fork your own version and pull-request it. If you are planning on adding another booru to the wrapper, please do it in a similar style to the currently existing methods.
|
||||
|
||||
Reference in New Issue
Block a user