Git Product home page Git Product logo

boorudex's Introduction

BooruDex

Library to access the booru website using public API. This library only support GET method, it means only listing and searching only. For other method like POST, contributions are welcomed.

CodeFactor

Download

Nuget

Overview

Currently BooruDex support the following websites:

Feature

  • Artist
    • Search for artist by name
  • Pool
    • Search for pool by name
    • List of post inside pool
  • Post
    • Search for multiple random image by tags
    • List of latest post update
  • Tag
    • Search for tags by tag name pattern
    • Search for tag related by other tag
  • Wiki
    • Search for wiki by title

Note Some client may not have some feature listed above, because there's no public API for it.

Feature by template

Only GET method.

Template Artist API Pool API Post API Tag API Wiki API
Danbooru ✔️ ✔️ ✔️ ✔️ ✔️
Gelbooru ✔️ ✔️
Gelbooru beta 0.2 ✔️
Moebooru ✔️ ✔️ ✔️ ✔️ ✔️

Benchmark

This benchmark compare with other library, BooruSharp

BenchmarkDotNet=v0.12.1, OS=Windows 10.0.18363.1256 (1909/November2018Update/19H2)
AMD FX-8800P Radeon R7, 12 Compute Cores 4C+8G, 1 CPU, 4 logical and 4 physical cores
.NET Core SDK=5.0.101
  [Host]    : .NET Core 5.0.1 (CoreCLR 5.0.120.57516, CoreFX 5.0.120.57516), X64 RyuJIT  [AttachedDebugger]
  MediumRun : .NET Core 5.0.1 (CoreCLR 5.0.120.57516, CoreFX 5.0.120.57516), X64 RyuJIT

Job=MediumRun  IterationCount=15  LaunchCount=2  
WarmupCount=10  
Method Mean Error StdDev Min Max Ratio RatioSD Rank Gen 0 Gen 1 Gen 2 Allocated
BooruDex 502.0 ms 85.06 ms 124.68 ms 371.9 ms 861.2 ms 1.00 0.00 1 - - - 78.38 KB
BooruSharp 506.2 ms 54.29 ms 76.11 ms 374.3 ms 690.9 ms 1.07 0.33 1 - - - 353.91 KB

Note Speed or perfomace may not accurate because internet connection or server response

This benchmark search 10 latest post from danbooru.

As of version 2.2.0, BooruDex changed all object models (Post, Tag, ..) from struct to class. So the memory(RAM) usage increased a little, before it was about 68.76 KB.

Refer to this repository for the benchmark log and source code.

Example

Get 10 random post from danbooru.donmai.us.

var client = new DanbooruDonmai();
var posts = await client.GetRandomPostAsync(10);
foreach (var post in posts)
{
    Console.WriteLine($"Id: { post.ID }");
    Console.WriteLine($"File url: { post.FileUrl }");
}

More example can be found here.

Documentation

For documentation: Wiki

Donation

Like this library? Please consider donation

ko-fi

boorudex's People

Contributors

dependabot-preview[bot] avatar shiroechi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

boorudex's Issues

HELP WANTED!

Template for e621.net

  • Implement all GET method
    it's easy to do, but there's a rate limit for request.
  • Can manage the limit rate (2 request/second)
    It can handle if there's many request at once. My idea is using queue, but I think it again it not efficient. Other template don't have this rate limit thing for request GET method.
    this what I don't know to handle it.

Do not clone and dispose

BooruDex/Booru/Booru.cs

Lines 821 to 826 in c89b2ff

using (var temp = await this.GetJsonResponseAsync<JsonDocument>(url))
{
obj = temp.RootElement.Clone();
}

don't clone the object then dispose it, if you do like that it will consume more CPU and RAM

Using 2 tags at the same time via DanbooruDonmai got an error about the number of tags.

Try to run this:

var a = new DanbooruDonmai();
var b = await a.GetRandomPostAsync(1, new string[] { "animated", "arknights" });

You'll get something like this

Unexpected error occured.
Status code = 422
Reason = Unprocessable Entity.

I don't know why, but when trying to GET /posts.xml?random=true&limit=1&tags=animated arknights it redirects you to /posts.xml?limit=1&tags=animated+arknights+random:1 and their API thinks that you are trying to find 3 tags instead of 2

Null HttpClient

BooruDex/Booru/Booru.cs

Lines 258 to 260 in c89b2ff

using (var request = new HttpRequestMessage(HttpMethod.Get, url))
using (var response = await this._HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead))
using (var stream = await response.Content.ReadAsStreamAsync())

BooruDex/Booru/Booru.cs

Lines 309 to 311 in c89b2ff

using (var request = new HttpRequestMessage(HttpMethod.Get, url))
using (var response = await this._HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead))
using (var stream = await response.Content.ReadAsStreamAsync())

When creating client with null HttpClient it not called the lazy option.

Get request on “Find similar”

Hi there. I am trying to make Booru desktop tool for finding similar images and getting their links (like they did it on yandere). Yesterday I looked through the functions of your library, but haven’t seen something alike. Is there any way I have access to this functionality, or it’s a tool for the websites’ developers use only. Thanks in advance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.