Skip to main content

A Python wrapper for the rule34.xxx API

Project description

Niko's Rule34 Wrapper

[!WARNING] The service this pulls media from is an NSFW service!!

[!IMPORTANT] This is still work in progress!! Bugs WILL show up!!

A python wrapper/downloader for rule34.xxx!!

Features

  • CLI Interface - Command-line tool for searching and listing posts from rule34.xxx with customizable tags and limits.
  • Unlimited Fetching - Supports fetching unlimited posts by paginating through API results (bypasses the 1000-post per-request limit).
  • Pool Support - Fetch posts from specific pools. I don't know of any other wrappers/downloaders that support pools.
  • tag_info support - Supports rule34's tag info stuff. This means that tags can be catagorized by their type (general, artist, character...).

Installation

Prerequisites

Optional for enhanced UI:

  • rich

[!NOTE] This should work on Windows. Otherwise, open an issue!

Installation through PyPi (if you're also using this as a library):

pip install nikos-rule34-wrapper rich # rich is optional

Installation through pipx (if you're only using this to download posts and stuff):

pipx install nikos-rule34-wrapper && pipx inject nikos-rule34-wrapper rich # rich is optional

Tested on:

  • Linux (Ubuntu)
  • MacOS (Tahoe)
  • Termux (although some extra setup is done for dependancies)

Usage

Run the CLI tool:

python -m rule34 --tags "-ai_generated -scat -3d kasane_teto" --limit 100 --download --destination /path/to/download/

...or if you installed with pipx, replace python -m rule34 with just rule34 (rule34 --tags "-ai_gener...)

Arguments

  • --tags (optional): Search tags (e.g., "vocaloid", "sort:score", "-ai_generated"). One of --tags, --pool-id, or --favorites-user-id must be specified.
  • --pool-id (optional): Pool ID to fetch posts from.
  • --favorites-user-id (optional): User ID to fetch favorites from.
  • --limit (optional): Number of posts to fetch (default 200, 0 for unlimited).
  • --download (flag): Enable downloading of posts.
  • --destination (required if downloading): Path to save downloaded files.
  • --reset-credentials (flag): Prompt to re-enter API credentials.

First Run

On first use, you'll be prompted for your API key and user ID. These are stored securely and reused in future runs.

Examples

[!NOTE] If you installed through pipx, remember to replace python -m rule34 with rule34.

[!IMPORTANT] Some systems use python3 instead of python. Try that if this doesn't work. This doesn't apply to those using pipx!

  • List posts without downloading:

    python -m rule34 --tags "kasane_teto sort:score" --limit 50
    
  • Download unlimited posts:

    python -m rule34 --tags "kasane_teto" --limit 0 --download --destination ./downloads # WILL download many files!!! It's okay to terminate with ctrl+C.
    
  • Reset credentials:

    python -m rule34 --tags "kasane_teto sort:score" --reset-credentials --print-posts --taginfo # Will prompt for credentials before listing
    
  • Fetch posts from a pool:

    python -m rule34 --pool-id 12345 --limit 50 --download --destination ./pool_downloads
    
  • Fetch posts from user favorites:

    python -m rule34 --favorites-user-id 4525852 --limit 100
    

API Reference

from rule34 import Client

client = Client("your_api_key", "your_user_id")
posts = client.list_posts("kasane_teto", limit=100)
for post in posts:
    print(post.file_url)

See client.py for full method details.

Contributing

Contributions are welcome!!! PLEASE open an issue or submit a pull request!!!

Planned features

  • [ ] Httpx instead of requests
  • [ ] Async support
  • [x] PyPi package

Published at https://pypi.org/project/nikos-rule34-wrapper/!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nikos_rule34_wrapper-1.0.4.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nikos_rule34_wrapper-1.0.4-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

Details for the file nikos_rule34_wrapper-1.0.4.tar.gz.

File metadata

  • Download URL: nikos_rule34_wrapper-1.0.4.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for nikos_rule34_wrapper-1.0.4.tar.gz
Algorithm Hash digest
SHA256 609bcf7d7abfbbcb43161617aed98a813064287dc263dda37d692cba5a1bf289
MD5 4da5d6c57592eb0c33a2ba9962df2e28
BLAKE2b-256 3f505c0dc348b2ed493ed13bfc87a9d362fb735cad76e0252b730c862c4aa417

See more details on using hashes here.

Provenance

The following attestation bundles were made for nikos_rule34_wrapper-1.0.4.tar.gz:

Publisher: python-publish.yml on niko-at-chalupa/nikos-rule34-wrapper

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nikos_rule34_wrapper-1.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for nikos_rule34_wrapper-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 c4e6b0df795d2ae1f927afc934b033dfb8144c7c07e1fc63a562dd800641e2ec
MD5 3fa4809b8bc90bd9df3c23da9fafddbb
BLAKE2b-256 11804d4e07e4ccc13e90dcfb974a8ac2eda7e47175962734f4bf16e9287b6310

See more details on using hashes here.

Provenance

The following attestation bundles were made for nikos_rule34_wrapper-1.0.4-py3-none-any.whl:

Publisher: python-publish.yml on niko-at-chalupa/nikos-rule34-wrapper

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page