Skip to main content

bdl

Async batch downloader and sync tool for booru boards (Gelbooru, Rule34, Xbooru, Safebooru, Danbooru, Konachan, Yande.re, Tbib, e621, e926).

Features

  • Async streaming downloads — asyncio + aiohttp, files streamed to disk in chunks, concurrency bounded by asyncio.Semaphore.
  • Four-level deduplication — uid in SQLite, the file already present on disk, an optional sha256 check, and a perceptual pHash so the same artwork reposted to another board under a new id is skipped too. The first three levels are free; the pHash has to see the bytes, so a repost is downloaded, recognised and then deleted instead of being kept.
  • Aspect-ratio filtering — --wallpapers, --avatars, or a custom --aspect-ratio MIN:MAX, applied after the API response so nothing extra is downloaded. Boards that omit image dimensions are kept by default; pass --aspect-unknown skip to drop them instead.
  • Tag-family blacklist — a root tag pulls in its related sub-tags from ~/.config/bdl/blacklist.txt, plus a per-run --blacklist override.
  • DNS-over-HTTPS and proxy support — a built-in DoHResolver (Cloudflare) works around local DNS blocks on image CDNs, and an upstream proxy can be set.
  • uvloop when available — the event loop switches to uvloop on every platform but Windows, which speeds up a batch of many small transfers.
  • Typo tolerance — a tag that is not in the dictionary is matched against the popular tags and corrected before the query goes out (mku → miku).
  • Image previews — inside Kitty, finished pictures are drawn once the batch ends as a compact gallery of thumbnail rows rather than a column running off the screen; --no-preview turns them off.
  • Interactive wizard — bdl on a terminal (or bdl tui) walks through the download: boards with checkboxes, tags with live tag suggestions, limit, sort order, rating, geometry and an optional list of tags to exclude, then prints a summary before starting. The interface ships in Russian (default) and English; questionary supplies the arrow-key menus and rich the section headers.
  • Machine-readable output — --json on search and status.

Installation

Requires Python 3.11+. The repository is Booru-Downloader-py; the console command it installs is bdl.

git clone https://github.com/wexqk-boo/Booru-Downloader-py.git
cd Booru-Downloader-py
python3 -m venv .venv
./.venv/bin/pip install -e .          # or: pip install -e '.[dev]' for tests/ruff

The package installs a single entry point: bdl.

To put it on PATH:

./install.sh          # symlink the entry point into ~/.local/bin
./install.sh --copy   # copy it instead
./install.sh --remove # uninstall

Run bdl on a terminal to open the wizard. Without a terminal it prints usage and exits 2, so scripts never block on a prompt. If an old install left a fish function named bdl, it shadows the binary — remove it (rm ~/.config/fish/functions/bdl.fish) and run functions -e bdl once; ./install.sh --remove cleans that up together with the stale helper.

rapidfuzz powers tag suggestions and typo correction; without it the code falls back to the standard-library difflib. imagehash and pillow enable perceptual dedup, and uvloop speeds up the event loop everywhere but Windows.

Usage

# Download every source, tag "miku", wallpaper aspect ratio only
bdl dl -s all -t "miku" --wallpapers

# Preview results without downloading
bdl search -s gelbooru -t "school_uniform" --limit 20

# Download statistics from the SQLite state
bdl status

# Daemon-style sync: repeated passes, already-downloaded posts skipped
bdl sync -s all -t "rating:general" --interval 900

# Blacklist management
bdl blacklist list
bdl blacklist add loli

Other subcommands: tui (interactive wizard), prune-stale (forget DB rows whose files are gone), config (get / set / show), and tags (tag suggestions).

prune-stale only inspects paths under the current output root, so a run against a temporary --out cannot forget the real library. Use --all to check every recorded path, or --out DIR to pick a different scope.

Wizard

bdl tui     # or bare `bdl` on a terminal, which reaches the same wizard

Rating choices are Safe / Suggestive / NSFW / All (--safe, --suggestive, --nsfw on the command line), and geometry offers Wallpapers, Avatars, a custom MIN:MAX range, or no filter. MIN:MAX accepts 1.5:1.8, 1,5:1,8, 1.5/1.8 and width:height shorthands such as 16:9 or 3:4.

The whole wizard is five screens and takes well under a minute: boards, the tag query, limit and geometry, an optional line of tags to exclude, then the summary. It never asks about concurrency — 8 parallel transfers keep a 100 Mbit line busy — and the JSON/sha256/re-download switches stay off unless you pass them to dl yourself.

The wizard asks for the output folder only until one is known: the first answer is saved to the config and later runs reuse it silently, unless BDL_OUT is set, which wins outright and is never written back. The exclusion step is a single comma-separated field — a root tag such as ai pulls in its whole family, an empty answer excludes nothing. Tag fields complete from the local Danbooru database as you type, and the run ends with a summary before the final confirmation.

Common flags for dl / sync: --limit, --per-page, --out, --concurrency, --sidecar, --checksum, --force, --min-score, --rating-include, --max-size-mb, --blacklist, --no-progress, --no-preview, --no-notify, --timeout.

Directory layout

Files are written as <out_root>/<source>/<bucket>/[videos/]/<filename>, with all sidecar JSON collected in a json/ folder:

<out_root>/<source>/
├── safe/            # ratings: safe, s, general, g
│   ├── <file>.jpg
│   ├── videos/      # mp4, webm, mov, avi, mkv, flv, m4v, wmv
│   └── json/        # <file>.jpg.json sidecars (with --sidecar)
├── suggestive/      # ratings: questionable, q, sensitive
└── nsfw/            # ratings: explicit, e

The default out_root comes from BDL_OUT, then the out key in the config file, then ~/Pictures/booru. Unknown or missing ratings land in nsfw/.

Configuration

  • Config file: ~/.config/bdl/config.json
  • Download state (SQLite): ~/.local/share/bdl/downloads.sqlite3
  • Tag blacklist: ~/.config/bdl/blacklist.txt
  • Tag database cache: ~/.cache/bdl/
  • Log: ~/.local/state/bdl/bdl.log

Environment variables:

  • BDL_OUT — override the output root (BOORU_DL_OUT still works).
  • BDL_LOG_FILE — duplicate logs to a file (BOORU_DL_LOG_FILE still works).
  • BDL_LANG — wizard language, ru (default) or en. Also settable through bdl config set lang en.
  • PROXY_URL — route requests through a proxy.

Board blocks

Xbooru's DAPI needs no API key, but Cloudflare fronts the site and sometimes challenges an IP with HTTP 403. Requests to Xbooru therefore carry a full set of browser headers. If the IP is still challenged, the affected files are counted as blocked instead of filling the screen with warnings, and the reason is reported once in the batch summary at the end. Setting PROXY_URL is the usual way out.

  • bdl config set out ~/Pictures/booru — default output root for every command that takes --out (BDL_OUT still wins over it).

Development

./.venv/bin/python -m pytest tests -q    # unit tests, no network
./.venv/bin/ruff check bdl tests

License

MIT

Metadata

Release files for booru-dl 2.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for booru-dl 2.1.0
File Size Uploaded Provenance Actions
booru_dl-2.1.0.tar.gz 91.0 kB Without provenance Details for booru_dl-2.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for booru-dl 2.1.0
File Interpreter ABI Platform Actions
booru_dl-2.1.0-py3-none-any.whl Python 3 none any Details for booru_dl-2.1.0-py3-none-any.whl

Total release size: 174.9 kB

Release files / booru_dl-2.1.0.tar.gz

Download URL booru_dl-2.1.0.tar.gz
Size 91.0 kB
Tags Source
SHA-256 checksum
How to use checksums
a3e36ca38c4d966839f3e861caebb29422ddc89595fb68c7d89a3653362c27bf
BLAKE2b-256 checksum
How to use checksums
40d1d53c50b4d48324cc1cf00967c807f93adc5d19acb819683fadd27c902402
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / booru_dl-2.1.0-py3-none-any.whl

Download URL booru_dl-2.1.0-py3-none-any.whl
Size 83.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5d46ba2c2a9812bc3dcd61da0ff8e33a899c578413191698be15dc4556a53bf8
BLAKE2b-256 checksum
How to use checksums
e0a043abd6b506cecd68903ecc5cf1d2b50c1a1f1ad3ea6406c0661d63776a30
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for booru-dl 2.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page