10 releases

0.2.0 Jan 19, 2024
0.1.9 Jan 19, 2024

#1990 in Web programming

MIT/Apache

33KB
883 lines

ci-badge crates.io version

booru-rs

An async Booru client for Rust

Overview

The client currently supports:

  • Gelbooru
  • Safebooru
  • Danbooru
  • Konachan
  • R34
  • 3DBooru
  • More... ?

Example

Remember to bring the Client trait into scope with use booru_rs::client::Client;

let posts = GelbooruClient::builder()
    .tag("kafuu_chino")
    .tag("2girls")
    .rating(GelbooruRating::General)
    .sort(GelbooruSort::Score)
    .limit(5)
    .random(true)
    .blacklist_tag(GelbooruRating::Explicit)
    .build()
    .get()
    .await
    .expect("There was an error retrieving posts from the API");

lib.rs:

Usage

use rusty_booru::{danbooru::{client::DanbooruClient, DanbooruRating}};
use rusty_booru::shared::{client::{WithClientBuilder, DispatcherTrait}, Sort};

#[tokio::main]
async fn main() {
    let posts = DanbooruClient::builder()
        .default_url("https://testbooru.donmai.us")
        .query(|q| {
            q.rating(DanbooruRating::General)
                .sort(Sort::Score)
                .limit(10)
        })
        .get()
        .await
        .expect("There was an error. (•-•)");

    match posts.first() {
        Some(post) => println!("{:?}", post),
        None => panic!("Well... \"No posts found?\""),
    }
}

Dependencies

~8–23MB
~327K SLoC