Skip to main content

nhentai.net API wrapper for doujins

Project description

forthebadge made-with-python

Kitsune

An asynchronous nhentai.net API wrapper and scraper

As of now the wrapper has most of the functionality the API has to offer, except for the endpoint for filtering galleries by tag which I didn't include in the wrapper due to the fact that the search endpoint can already do that. The only thing left to do is to improve the quality of the code, implement GIF downloading which, according to how they are distributed across nhentai image repositories, will be quite troublesome and writing the documentation.

Only contributions I allow will be accepted. This will be worked on only in my free time.

Current capabilities:

  • nhentai.net API endpoints data requesting
  • Searching and filtering with webscraping
  • Ratelimit handling
  • Downloading done via threads

Pre-release:

  • Extra polishing, some extra refactoring and last touches.
  • Licensing, uploading the package and guide on how to use.

Post-release:

  • GIF downloading support.
  • Even more refactoring.
  • Tweaks and changes for the http handler.

Installation

Python 3.8+

pip install kitsune-nh

How-to-use guide

The main way to instantiate the wrapper class is via an async context manager which takes care of creating and closing the HTTP session internally.

import asyncio

from kitsune import Kitsune

async def main():
    async with Kitsune() as client: 
        ...

You can also opt to pass your own HTTP session.

import aiohttp

from kitsune import Kitsune

async def main():

    session = aiohttp.ClientSession()

    async with Kitsune.from_session(session) as client: 
        ...

Now that you have your instance of the wrapper, using it is fairly simple. Some examples below.

import aiohttp

from kitsune import Kitsune, Popularity, Tag, Artist, Character, Parody, Group 

async def main():
    async with Kitsune(loop = your_loop) as client: # You can also pass your own loop, which will handle the ratelimits  

        gallery = await client.fetch_gallery(312781) # Fetching a gallery/doujinshi

        galleries = await client.fetch_galleries([312781, 31286, 9294]) # Multiple

        related = await client.fetch_related(312781) # Related

        random_gallery = await client.fetch_random() # Random

        homepage = await client.fetch_homepage() # Homepage

        shelf = await client.search([Tag["futanari"], Tag["kitsune"], popularity = Popularity.ALL_TIME) # Query/filter search

        comments = await client.fetch_comments(gallery.id) # Fetching the comments from a doujin

More examples and explanations can be found on the documentation.

Special thanks to hentai-chan for sharing the API endpoints. They were necessary for this async version of the wrapper to work.

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

kitsune-nh-0.0.3.tar.gz (21.1 kB view details)

Uploaded Source

Built Distribution

kitsune_nh-0.0.3-py3-none-any.whl (21.1 kB view details)

Uploaded Python 3

File details

Details for the file kitsune-nh-0.0.3.tar.gz.

File metadata

  • Download URL: kitsune-nh-0.0.3.tar.gz
  • Upload date:
  • Size: 21.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5

File hashes

Hashes for kitsune-nh-0.0.3.tar.gz
Algorithm Hash digest
SHA256 35f6ec7312c3765ec79f4eba89f8660d12849fa61ad9d638cc93d0637a5e4877
MD5 d59d4cf2b059345b9ec80feff2dab245
BLAKE2b-256 931a9424caff8d06271e37e2f946be6a275dc712cf9da6bc57ebff8667516f3d

See more details on using hashes here.

File details

Details for the file kitsune_nh-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: kitsune_nh-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 21.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5

File hashes

Hashes for kitsune_nh-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4b5fe52e0f7182b54f2b798b0f75c668f02d63c6c0006ae32f24ce0b4d98e16d
MD5 29a15558e1e9352f368316a4976e1897
BLAKE2b-256 7220968bcce1beb9e8caea39608c8de60dc0716b7f21163a44e5ff47713dfbf0

See more details on using hashes here.

Supported by

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