Coder Social home page Coder Social logo

imoutochan / imoutobooruparser Goto Github PK

View Code? Open in Web Editor NEW
10.0 3.0 0.0 265 KB

Library designed to parse data from booru-like websites such as danbooru.donmai.us, yande.re, gelbooru.com, and chan.sankakucomplex.com.

License: MIT License

C# 100.00%
image tags tag anime parser booru danbooru sankakucomplex sankakuchannel yandere

imoutobooruparser's Introduction

Imouto.BooruParser

NuGet license

The dotnet library for retrieving info from booru sites (chan.sankakucomplex.com, danbooru.donmai.us, yande.re, gelbooru.com). You can get individual posts, tags/notes history, and search by tags. Install as NuGet package:

Install-Package Imouto.BooruParser
<PackageReference Include="Imouto.BooruParser" Version="3.*" />

Version 3.3.0

  • Sankaku is child of devil and was broken once again. Removed old auth chan. part as now all logins goes throw beta.

Version 3.2.0

  • Added Rule34, they have a lot of tagged pay-walled staff and I will be using them as tag source for this stuff. No auth is required for now.
  • Sankaku was broken once again. This time they changed their auth flow on their old site. PassHash no longer works. Without auth you also can't get all of post tags (only 20 general tags). I fixed it (only god know for how long). You have to provide login and password and it should work.

Version 3.1

Once again sankaku broke everything. It's now recommended to provide login and pass_hash for sankaku in order to receive all tags from posts. Without it you can only get 20 general tags.

Version 3.0

Have to increment major version due to breaking change in danbooru api usage. Now you have to provide your own user agent for your bot in danbooru settings, otherwise danbooru requests would fail with 403 (recent change on their side).

Version 2.0 released!

The new version of this library has been released. It's a complete rewrite and has a lot of breaking changes. Please don't update unless you're ready to spent some time in refactoring and reading.

The new version has gelbooru as partly supported booru. It doesn't provide a way to get tags or notes history, but you can search and retrieve posts by id or md5. To consume this library you should use IBooruApiLoader interface. The library provides following implementations, one for each booru:

var loader = new DanbooruApiLoader(...);
var loader = new YandereApiLoader(...);
var loader = new SankakuApiLoader(...);
var loader = new GelbooruApiLoader(...);

The recommended way to consume them is to register them in your container:

services.AddBooruParsers();

// OPTIONAL
// It'ts nessesary for Sankaku auth management. 
// You can skip it, if you don't plan to access sankaku with authorization.
services.AddMemoryCache();

But you can also register them yourself. You also need to provide configuration for booru if you want to have more relaxed limits:

services.Configure<DanbooruSettings>(Configuration.GetSection("Danbooru"));
services.Configure<GelbooruSettings>(Configuration.GetSection("Gelbooru"));
services.Configure<SankakuSettings>(Configuration.GetSection("Sankaku"));
services.Configure<YandereSettings>(Configuration.GetSection("Yandere"));

Each settings has PauseBetweenRequestsInMs param which defines a pause between requests. 0 means you can run your requests in parallel and any positive number means that all requests would be called with the provided pause in ms between them. It's important to have some reserves to not get banned.

! Sankaku is a difficult case for the authorization. It requires access and refresh tokens (you can extract them from cookies), but refresh token has to be updated. So SankakuSettings has a callback method SaveTokensCallbackAsync that will be called, when it's necessary to update refresh and access tokens. It's you responsibility to store them somewhere and pass on the next application start.

Simplest usage

var loader = new DanbooruApiLoader(
    new PerBaseUrlFlurlClientFactory(), 
    Options.Create(new DanbooruSettings()))
    
var post = await loader.GetPostAsync(5628013);
Console.WriteLine(post.Md5);

Version 1.x.x

Simplest usage

var username = "user";~~~~
var apiKey = "HBArbAk4WcKTSeAfsyBO";
var delayBetweenRequestsInMs = 1240;

var danbooruLoader = new DanbooruLoader(username, apiKey, delayBetweenRequestsInMs);
var post = await danbooruLoader.LoadPostAsync(5628013);
Console.WriteLine(post.Md5);

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.