Giter Site home page Giter Site logo

kob-kirito / boorusharp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from xwilarg/boorusharp

0.0 0.0 0.0 535 KB

A C# library to browse Booru websites (Gelbooru, Konachan, etc...) easily

License: GNU General Public License v3.0

C# 99.74% Smalltalk 0.17% Shell 0.09%

boorusharp's Introduction

BooruSharp BooruSharp.Others
NuGet NuGet
Nuget Nuget
GitHub CI AppVeyor CI
Build (GitHub CI) Build (AppVeyor)

codecov Unit tests CodeFactor

BooruSharp

BooruSharp is a C# library to browse Booru websites easily
You can download it from NuGet:

Install-Package BooruSharp
Install-Package BooruSharp.Others

BooruSharp currently handle the following websites:

  • booru.allthefallen.moe
  • danbooru.donmai.us
  • e621.net
  • e926.net
  • furry.booru.org
  • gelbooru.com
  • konachan.com
  • lolibooru.moe
  • realbooru.com
  • rule34.xxx
  • safebooru.org
  • sakugabooru.com
  • beta.sankakucomplex.com
  • xbooru.com
  • yande.re

BooruSharp.Others allow to handle more websites that aren't booru:

  • pixiv.net

Documentation

Version >= 2.0.0: https://boorusharp.zirk.eu/
Version <= 1.4.8: https://github.com/Xwilarg/BooruSharp/wiki
Transition from 1.4.8 to 2.0.0: https://boorusharp.zirk.eu/transition.html

Features availability

Booru Multiple Random Images Post by ID Post by MD5 Tag by ID Comment API Last Comments API Wiki API Related Tag API Post Count API Favorite API
Atfbooru ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
Danbooru Donmai ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
E621 ✔️ ✔️
E926 ✔️ ✔️
Furry Booru ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
Gelbooru ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
Konachan ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
Lolibooru ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
Realbooru ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
Rule 34 ✔️ ✔️ ✔️ ✔️
Safebooru ✔️ ✔️ ✔️ ✔️
Sakugabooru ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
Sankaku Complex ✔️ ✔️ ✔️ ✔️
Xbooru ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
Yandere ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
Pixiv ✔️ ✔️ ✔️

Examples

Random image:

BooruSharp.Booru.Gelbooru booru = new BooruSharp.Booru.Gelbooru();
BooruSharp.Search.Post.SearchResult result = await booru.GetRandomPostAsync("hibiki_(kantai_collection)", "school_swimsuit");

Console.WriteLine("Image preview URL: " + result.previewUrl.AbsoluteUri + Environment.NewLine +
                  "Image URL: " + result.fileUrl.AbsoluteUri + Environment.NewLine +
                  "Image is safe: " + (result.rating == BooruSharp.Search.Post.Rating.Safe) + Environment.NewLine +
                  "Tags on the image: " + String.Join(", ", result.tags));

Get many random images at once:

BooruSharp.Booru.SankakuComplex booru = new BooruSharp.Booru.SankakuComplex();
BooruSharp.Search.Post.SearchResult[] result = await booru.GetRandomPostsAsync(10, "ifrit_(arknights)", "silence_(arknights)");

Console.WriteLine(string.Join(Environment.NewLine, result.Select(x => "Random Image: " + x.fileUrl)));

Get tag:

BooruSharp.Booru.Safebooru booru = new BooruSharp.Booru.Safebooru();
BooruSharp.Search.Tag.SearchResult result = await booru.GetTagAsync("cirno");

Console.WriteLine("Tag type: " + result.type + Environment.NewLine +
                  "ID: " + result.id);

Get Wiki entry:

BooruSharp.Booru.Konachan booru = new BooruSharp.Booru.Konachan();
BooruSharp.Search.Wiki.SearchResult result = await booru.GetWikiAsync("loli");

Console.WriteLine("Description: " + result.body + Environment.NewLine +
                  "ID: " + result.id + Environment.NewLine +
                  "Created at: " + result.creation.ToString("dd/MM/yy HH:mm:ss") + Environment.NewLine +
                  "Last update at: " + result.lastUpdate.ToString("dd/MM/yy HH:mm:ss"));

Get related tags:

BooruSharp.Booru.Yandere booru = new BooruSharp.Booru.Yandere();
BooruSharp.Search.Related.SearchResult[] results = await booru.GetRelatedAsync("see_through");

Console.WriteLine(String.Join(Environment.NewLine,
    results.Select(delegate (BooruSharp.Search.Related.SearchResult res) { return ("Name: " + res.name +" (" + res.count + ")"); })));

Get comments:

BooruSharp.Booru.Lolibooru booru = new BooruSharp.Booru.Lolibooru();
BooruSharp.Search.Comment.SearchResult[] results = await booru.GetCommentAsync(134097);

Console.WriteLine(String.Join(Environment.NewLine,
    results.Select(delegate (BooruSharp.Search.Comment.SearchResult res) { return ("Author: " + res.authorName + ", the " + res.creation.ToString("dd/MM/yy HH:mm:ss") + " - " + res.body); })));

Add to favorite:

BooruSharp.Booru.Safebooru booru = new BooruSharp.Booru.Safebooru();
booru.SetBooruAuth(new BooruSharp.Booru.BooruAuth("yourUserId", "yourPasswordHash")); // See https://boorusharp.zirk.eu/#authentification
await booru.AddFavoriteAsync(1759793);

Get all character tags containing a string:

BooruSharp.Booru.Yandere yandere = new BooruSharp.Booru.Yandere();
BooruSharp.Search.Tag.SearchResult[] results = await yandere.GetTagsAsync("tsukiko");
Console.WriteLine(String.Join(Environment.NewLine,
	results.Where(delegate (BooruSharp.Search.Tag.SearchResult res) { return (res.type == BooruSharp.Search.Tag.TagType.Character); })
           .Select(delegate (BooruSharp.Search.Tag.SearchResult res) { return (res.name); })));

Want to contribute?

Feel free to open a pull request.

Need more help?

Feel free to open an issue or come ask on Discord.

boorusharp's People

Contributors

kob-kirito avatar n-ski avatar xwilarg avatar

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.