Skip to main content

lunafind

PyPI downloads PyPI version PyPI pyversions

Search, filter, inspect, download posts from Danbooru/Safebooru and find them back from the command line without setting up any service or database.

Suitable for daily terminal usage, usable for scripts and as a library for Python 3.6+.

See also lunasync to automatically download and keep in sync particular tags using lunafind, similar to Danbooru tag subscriptions or saved searches.

Features

  • Operate on tag searches, URLs or file paths
  • Combine results from multiple searches
  • Specify custom page ranges, or just get everything
  • Filter and order booru results to work around the two tags search limit
  • Optional partial/fuzzy tag matching for filter and local searches
  • Search downloaded posts by tags as if they were on a booru, without the hassle of setting up one
  • Instant results from local searches in most cases after indexing
  • Fast multithreaded downloads; 8 downloads in parallel by default
  • Supports operating on post media (image, ugoira WebM, etc), info, notes, artist commentaries:
    • Getting the URLs or file/folder paths
    • Printing on standard output
    • Downloading

Local searches performance

The first time a local post search is done, an index file to speed up future searches will be automatically created and updated when new post directories exist or are removed.

Test with ~165 000 posts
AMD FX-8300 (8 cores, 3.3GHz), TOSHIBA DT01ACA2 7200 RPM HDD, BTRFS file system, Void Linux 4.18.14 x86_64:

  • It takes about 2m30s - 3m to index everything from scratch
  • After this, search results start coming instantly unless --random or --order is used.
  • Searches finish completely in 8-20s

Test with ~60 000 posts
Celeron B815 (2 cores, 1.60GHz), 5400 RPM HDD, BTRFS file system, Void Linux 4.18.20 x86_64:

  • About 4mn to index everything from scratch
  • Results come instantly
  • Searches finishes in ~20s

Command line usage

Downloading to the current folder every post tagged blonde and 2girls (default booru is https://danbooru.donmai.us):

    lunafind "blonde 2girls" --limit 200 --pages all --download .

Searching through the posts we just downloaded, printing image paths for the results:

    lunafind "blonde blue_eyes rating:s score:>5" --source . --show-location media

See lunafind --help for all options and examples.

Python usage

No real documentation yet. Three main classes are provided:

  • Post: represents a local or remote single post, with its info, media, notes and artcom (artist commentary).

  • Album: works like a dictionary of Post, where keys are the post IDs. Has magic methods and operators to facilitate working with them. Can be filtered, ordered, downloaded, and more.

  • Stream: an efficiant lazy iterator yielding posts. Can be filtered and multithread-downloaded.

Reproducing the command line examples in the section above:

    from lunafind import Stream

    Stream("blonde 2girls", limit=200, pages="all").download()

    for post in Stream("blonde blue_eyes rating:s score:>5", client="."):
        print(post.get_location("media"))

Installation

Requires Python 3.6+ and pip (for automatic easy install).
Tested on GNU/Linux and Windows 7, probably works on OSX and other POSIX systems.
As root:

    pip3 install -U lunafind

Metadata

Release files for lunafind 0.5.5

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

Source distribution (sdist)

Source distribution for lunafind 0.5.5
File Size Uploaded
lunafind-0.5.5.tar.gz 28.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lunafind 0.5.5
File Interpreter ABI Platform
lunafind-0.5.5-py3-none-any.whl Python 3 none any Details

Total release size: 77.2 kB

Release files / lunafind-0.5.5.tar.gz

Download URL lunafind-0.5.5.tar.gz
Size 28.4 kB
Tags Source
SHA-256 checksum
How to use checksums
cf8d95ea171d050be81c1695bc0f86e1223b72f6dcc58fe13b7c8abdb9b4249e
BLAKE2b-256 checksum
How to use checksums
ef09a6003afae0ffd2b7675405b8dae95a370920786a454e58fa590642d2cda1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.8.0 tqdm/4.42.1 CPython/3.8.5

Release files / lunafind-0.5.5-py3-none-any.whl

Download URL lunafind-0.5.5-py3-none-any.whl
Size 48.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
92f5fda13f069ba37907964800c301c6c62242e4f28eec9a0fdde9f0661348f1
BLAKE2b-256 checksum
How to use checksums
9a5fc93c3b1a622722e07746a3c8fd5a202b9eccf1583723dbdd661fa4bdbd56
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.8.0 tqdm/4.42.1 CPython/3.8.5

Release history Release notifications | RSS feed

This release

0.5.5 This release

2 release files

0.5.4

2 release files

0.5.1

2 release files

0.5.0

2 release files

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