Module async_queue

Source
Expand description

Queue used specifically to download, filter and save posts found by an Extractor.

§Example usage

Conveniently using the same example from here

use imageboard_downloader::*;
use std::path::PathBuf;

async fn download_posts() {
    let tags = ["umbreon", "espeon"]; // The tags to search
     
    let safe_mode = false; // Setting this to true, will ignore searching NSFW posts

    let disable_blacklist = false; // Will filter all items according to what's set in GBL

    let mut unit = DanbooruExtractor::new(&tags, safe_mode, disable_blacklist); // Initialize

    let prompt = true; // If true, will ask the user to input thei username and API key.

    unit.auth(prompt).await.unwrap(); // Try to authenticate

    let start_page = Some(1); // Start searching from the first page

    let limit = Some(50); // Max number of posts to download

    let posts = unit.full_search(start_page, limit).await.unwrap(); // and then, finally search

    let sd = 10; // Number of simultaneous downloads.

    let limit = Some(1000); // Max number of posts to download

    let cbz = false; // Set to true to download everything into a .cbz file

    let mut qw = Queue::new( // Initialize the queue
        ImageBoards::Danbooru,
        posts,
        sd,
        Some(unit.client()), // Re-use the client from the extractor
        limit,
        cbz,
    );

    let output = Some(PathBuf::from("./")); // Where to save the downloaded files or .cbz file

    let id = true; // Save file with their ID as the filename instead of MD5

    qw.download(output, id).await.unwrap(); // Start downloading
}

Structs§

Queue
Struct where all the downloading will take place