All Projects → Xwilarg → BooruSharp

Xwilarg / BooruSharp

Licence: MIT license
A C# library to browse Booru websites (Gelbooru, Konachan, E621...) easily

Programming Languages

C#
18002 projects
shell
77523 projects

Projects that are alternatives of or similar to BooruSharp

GelbooruEnhancement
Image Viewer and Endless Scroll userscripts for Gelbooru and various other boorus
Stars: ✭ 41 (-10.87%)
Mutual labels:  booru, gelbooru, sankakucomplex, konachan, e621, rule34
Hideri
A fully-featured bot for discord, supporting popular sites like reddit, hitomila, tsumino, nhentai, exhentai, and more
Stars: ✭ 18 (-60.87%)
Mutual labels:  booru, danbooru, gelbooru, konachan, rule34, safebooru
app
An e621/e926 client, fetch and download posts and pools!
Stars: ✭ 14 (-69.57%)
Mutual labels:  booru, e621, e926
scripter
一些脚本和工具
Stars: ✭ 20 (-56.52%)
Mutual labels:  booru, danbooru, konachan
Gallery Dl
Command-line program to download image galleries and collections from several image hosting sites
Stars: ✭ 4,199 (+9028.26%)
Mutual labels:  danbooru, pixiv
Aqua-Bot
디스코드 NSFW 챗봇 아쿠아 봇입니다.
Stars: ✭ 13 (-71.74%)
Mutual labels:  pixiv, rule34
decensooru
Decensoring addon for Better Better Booru.
Stars: ✭ 30 (-34.78%)
Mutual labels:  booru, danbooru
Boorunaut
A taggable imagebord built in Django. Based on Danbooru.
Stars: ✭ 18 (-60.87%)
Mutual labels:  booru, danbooru
danbooru-ruby-grabber
Danbooru, Konachan, Behoimi (3dbooru) and Yandere images downloader
Stars: ✭ 39 (-15.22%)
Mutual labels:  danbooru, konachan
PickTrue
豆瓣相册下载, A站下载器,Artstation Downloader, Pixiv Downloader, 花瓣网(huaban.com)图片下载器
Stars: ✭ 129 (+180.43%)
Mutual labels:  pixiv
OPQ-SetuBot
基于botoy和OPQBot的色图机器人
Stars: ✭ 194 (+321.74%)
Mutual labels:  pixiv
pxnyan
An application powered by Flutter.
Stars: ✭ 47 (+2.17%)
Mutual labels:  pixiv
Pikax
一个基于requests的P站下载器/ A pixiv downloader based on requests
Stars: ✭ 49 (+6.52%)
Mutual labels:  pixiv
SetuAPI
色图API
Stars: ✭ 39 (-15.22%)
Mutual labels:  pixiv
e621 downloader
E621 and E926 downloader made in the Rust programming langauge.
Stars: ✭ 39 (-15.22%)
Mutual labels:  e621
moebooru-android
Moebooru client for Android. This project has been replaced by https://github.com/flexbooru/flexbooru
Stars: ✭ 35 (-23.91%)
Mutual labels:  booru
Hybooru
Hydrus-based booru-styled imageboard in React
Stars: ✭ 53 (+15.22%)
Mutual labels:  booru
WaifuLite
Super Resolution for Anime image, lightweight implementation
Stars: ✭ 20 (-56.52%)
Mutual labels:  danbooru
pixivcs
Pure C# implementation of Pixiv API
Stars: ✭ 33 (-28.26%)
Mutual labels:  pixiv
Aya
your globally distributed waifu storage
Stars: ✭ 32 (-30.43%)
Mutual labels:  booru
BooruSharp BooruSharp.Others
NuGet NuGet
Nuget Nuget
CI Code Quality Coverage
Build (GitHub CI) Codacy Badge Codacy Badge

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
  • derpibooru.org
  • e621.net
  • e926.net
  • gelbooru.com
  • konachan.com
  • lolibooru.moe
  • ponybooru.org
  • realbooru.com
  • rule34.xxx
  • safebooru.org
  • sakugabooru.com
  • beta.sankakucomplex.com
  • twibooru.org
  • xbooru.com
  • yande.re

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

  • pixiv.net

Documentation

You can either use the documentation or check the examples below
If you have any question, feel free to contact me

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 ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
Derpibooru ✔️ ✔️ ✔️ ✔️
E621 ✔️ ✔️ ✔️
E926 ✔️ ✔️ ✔️
Gelbooru ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
Konachan ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
Lolibooru ✔️ ✔️ ✔️ ✔️ ✔️
Ponybooru ✔️ ✔️ ✔️ ✔️
Realbooru ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
Rule 34 ✔️ ✔️ ✔️ ✔️
Safebooru ✔️ ✔️ ✔️ ✔️
Sakugabooru ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
Sankaku Complex ✔️ ✔️ ✔️ ✔️
Twibooru ✔️ ✔️ ✔️ ✔️
Xbooru ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
Yandere ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
Pixiv ✔️ ✔️ ✔️

Additional notes on Pixiv

Pixiv also have 2 methods to download an image (ImageToByteArrayAsync) or a preview (PreviewToByteArrayAsync), it'll give you a byte array given a SearchResult

Please make note that you also need to provide at least one tag for the following methods:

  • GetLastPostsAsync
  • GetPostCountAsync
  • GetRandomPostAsync

Examples

Random image

var booru = new BooruSharp.Booru.Gelbooru();
var 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));

Random image (Pixiv)

var booru = new BooruSharp.Others.Pixiv();
await booru.LoginAsync("[refreshToken]"); // See https://github.com/Xwilarg/BooruSharp/#pixiv
var result = await booru.GetRandomPostAsync("シンボリルドルフ(ウマ娘)");
File.WriteAllBytes($"output{Path.GetExtension(result.FileUrl.AbsolutePath)}", await b.ImageToByteArrayAsync(result)); // Save the image in a file

Many random images at once

var booru = new BooruSharp.Booru.SankakuComplex();
var results = await booru.GetRandomPostsAsync(10, "ifrit_(arknights)", "silence_(arknights)");

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

Get tag

var booru = new BooruSharp.Booru.Safebooru();
var result = await booru.GetTagAsync("cirno");

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

Get Wiki entry

var booru = new BooruSharp.Booru.Konachan();
var 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

var booru = new BooruSharp.Booru.Yandere();
var 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

var booru = new BooruSharp.Booru.Lolibooru();
var 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

var booru = new BooruSharp.Booru.Safebooru();
booru.SetBooruAuth(new BooruSharp.Booru.BooruAuth("yourUserId", "yourPasswordHash")); // See https://github.com/Xwilarg/BooruSharp/#booru
await booru.AddFavoriteAsync(1759793);

Get all character tags containing a string

var yandere = new BooruSharp.Booru.Yandere();
var 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); })));

Authentification

Authentification is done by creating a new instance of BooruAuth is specifying it to your Booru instance

E621 / E926

userId is your username
passwordHash is your api key, to get it go to your account page and then in "Manage API Access"

Derpibooru / Poniboory / Twibooru

userId need to be an empty string
passwordHash is your api key, go on the website at the top left hover your profile icon, go in "Account", you'll see your API key there

Others booru

For booru authentification, you'll need your user id and your password hash
To get it, I advise you to go on an image, open the developer panel (F12) and go in "Network"
Then press the button to add the image to your favorite and look at the "Cookies" section of the last request Authentification

Pixiv

For Pixiv authentification, please use LoginAsync with a refresh token
To get your refresh token, you can follow this tutorial: https://gist.github.com/ZipFile/c9ebedb224406f4f11845ab700124362

Want to contribute

Feel free to open a pull request.

Need more help

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].