Skip to main content

pyszuru

Python interface for szurubooru

Installation: pip install pyszuru

Usage

Creating API Instance

import pyszuru
mybooru = pyszuru.API(
    "https://example.com/booru",
    username="alice",
    # Authenticate with a password
    password="hunter2",
    # Or use a token
    token="my-token-string",
    # Optionally specify a API base URL if it differs from the default configuration
    # api_url="/booru-api", <-- relative to base URL
    # api_url="https://api.example.com/booru", <-- new absolute base
)

Working with tags

Note: it is reccomended to use the factory functions outlined below instead of calling the Tag constructor directly.

Get existing tag

Get an existing tag from the booru by referencing it by name

marvel_comics_tag = mybooru.getTag("marvel_comics")

Create new tag

Create a new tag, must specifiy a primary name only

spiderman_tag = mybooru.createTag("spiderman")

Alter properties of tag

spiderman_tag.implications = spiderman_tag.implications + [marvel_comics_tag]
spiderman_tag.push()

Working with posts

Note: it is reccomended to use the factory functions outlined below instead of calling the Post constructor directly.

Get existing post

my_old_post = mybooru.getPost(1337)

Create a post

with open("image.jpg", "rb") as f:
    file_token = mybooru.upload_file(f)
my_new_post = mybooru.createPost(file_token, "safe")

Alter tags of a post

my_new_post.tags = [marvel_comics_tag, spiderman_tag]
my_new_post.push()

Working with pools

Note: it is reccomended to use the factory functions outlined below instead of calling the Pool constructor directly.

Get existing pool

Get an existing pool from the booru by referencing it by name

some_pool = mybooru.getPool("some_pool")

Create new pool

Create a new pool, must specifiy a primary name only

other_pool = mybooru.createPool("other_pool")

Alter properties of pool

other_pool.posts = [my_old_post, my_new_post]
other_pool.push()

Searching

Searching across tags, posts, and pools

unused_tags = mybooru.search_tag("usages:0")

for post in mybooru.search_post(
    "marvel_comics type:image special:fav", show_progress_bar=True
):
    wget.download(post.content)

for pool in mybooru.search_pool(my_query):
    pool.category = "coolpool"
    pool.push()

Reverse image search

with open("similar.jpg", "rb") as f:
    similar_file_token = mybooru.upload_file(f)
result = mybooru.search_by_image(similar_file_token)
if result:
    if any(x.exact for x in result):
        raise Exception("Found an exact match")
    else:
        warnings.warn(f"Found {len(result)} similar posts")

Metadata

Release files for pyszuru 0.4.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 pyszuru 0.4.0
File Size Uploaded Provenance Actions
pyszuru-0.4.0.tar.gz 23.4 kB Without provenance Details for pyszuru-0.4.0.tar.gz

Built distribution (wheel)

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

Total release size: 47.8 kB

Release files / pyszuru-0.4.0.tar.gz

Download URL pyszuru-0.4.0.tar.gz
Size 23.4 kB
Tags Source
SHA-256 checksum
How to use checksums
f2ab5cf0995eb4e074d7f91b1c88b0373a076c5a7f9d939e918a1f6092b9bc37
BLAKE2b-256 checksum
How to use checksums
fc8964cd2f0206f9a24a4996d2d56f97e60dbd83fce1371eb20c26a35246abca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.8

Release files / pyszuru-0.4.0-py3-none-any.whl

Download URL pyszuru-0.4.0-py3-none-any.whl
Size 24.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8bb38ca44550628a096be7d4201c99225ee3a5c5e7fee6b49f27fe6e780a48e0
BLAKE2b-256 checksum
How to use checksums
f1efe17d640dd3729c36246376cb9ba9f1dc256a0d6e178ebe986cb254fde977
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.8

Security for pyszuru 0.4.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