Skip to main content

Implements a wrapper class around nhentai's RESTful API.

Project description

“De gustibus non est disputandum.”

Python Hentai API Wrapper

English | 简体中文

This python package implements a wrapper class around nhentai's RESTful API. Please be aware that this is not an official API, technical questions about nhentai.net should be redirected to support@nhentai.com. Further note that the content of this module is generally considered NSFW. Finally, I would like to comment at this point that you should under no circumstances use this module to make an unreasonable amount of requests in a short period of time.

Installation

Get the most recent stable release from PyPI:

pip install hentai --only-binary all
Dev Notes for Contributors

Alternatively, if you're looking to make a contribution fork this repository and run

python -m venv venv/
source venv/bin/activate # For Windows: .\venv\Scripts\activate
python -m pip install --upgrade pip
pip install -r requirements/dev.txt
# additionally install the following dependencies
pip install flake8 pytest wheel
# run all unit tests
pytest --verbose -s
# create wheel
python setup.py bdist_wheel --universal

Make sure to checkout rec-hentai so that your work is up-to-date with the next release candidate. Don't implement any features that are incompatible with version 3.7+ of python.

Documentation

You can find the documentation online, or use the wiki to learn more about this module.

Basic Usage

Hentai makes it very easy to browse through nhentai.net. It implements a flat namespace for easy access of all their endpoints:

from hentai import Hentai, Format

doujin = Hentai(177013)

# True
Hentai.exists(doujin.id)

# METAMORPHOSIS
print(doujin.title(Format.Pretty))

# [Tag(id=3981, type='artist', name='shindol', url='https://nhentai.net/artist/shindol/', count=279)]
print(doujin.artist)

# ['dark skin', 'group', ... ]
print([tag.name for tag in doujin.tag])

# 2016-10-18 12:28:49+00:00
print(doujin.upload_date)

# ['https://i.nhentai.net/galleries/987560/1.jpg', ... ]
print(doujin.image_urls)

# get the source
doujin.download(progressbar=True)

Apart from that, hentai.Utils also provides a handful of miscellaneous helper methods:

from hentai import Utils, Sort, Option, Tag
from pathlib import Path

print(Utils.get_random_id())

# recommend me something good!
print(Utils.get_random_hentai())

# advanced search with queries
for doujin in Utils.search_by_query('tag:loli', sort=Sort.PopularWeek):
    print(doujin.title(Format.Pretty))

# print all character names from all doujins
for character in Tag.list(Option.Character):
    print(character.name)

# store custom meta data as JSON file to disk
popular_loli = Utils.search_by_query('tag:loli', sort=Sort.PopularWeek)
custom = [Option.ID, Option.Title, Option.Epos]
Utils.export(popular_loli, filename=Path('popular_loli.json'), options=custom)

See also https://nhentai.net/info/ for more information on search queries.

Command Line Interface

Starting with version 3.2.4, this module also provides a rudimentary CLI for downloading doujins within the terminal:

# get help
hentai --help

# download this doujin to the CWD
hentai download --id 177013

# check the module version
hentai --version

Get In Touch

You can reach me at dev.hentai-chan@outlook.com for private questions and inquires that don't belong to the issue tab.

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

hentai-3.2.10.tar.gz (1.3 MB view details)

Uploaded Source

Built Distribution

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

hentai-3.2.10-py3-none-any.whl (1.3 MB view details)

Uploaded Python 3

File details

Details for the file hentai-3.2.10.tar.gz.

File metadata

  • Download URL: hentai-3.2.10.tar.gz
  • Upload date:
  • Size: 1.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.7.9

File hashes

Hashes for hentai-3.2.10.tar.gz
Algorithm Hash digest
SHA256 1b9f4e03fad69a4a61502534db81683e299969af9d986ec643d092771e537846
MD5 de240c4a6eaa60de1ead688906c3e6bd
BLAKE2b-256 cf8429e5740449d37e50581aed5e92f0e3315d6d4924aa6c85cfcecc125a1e2c

See more details on using hashes here.

File details

Details for the file hentai-3.2.10-py3-none-any.whl.

File metadata

  • Download URL: hentai-3.2.10-py3-none-any.whl
  • Upload date:
  • Size: 1.3 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.7.9

File hashes

Hashes for hentai-3.2.10-py3-none-any.whl
Algorithm Hash digest
SHA256 62ffe034bc6f0e7ed4cc17cd0d2e689c816dafb39e831d952206b8a3c95e9979
MD5 a55f35dfea08dea1dc9babd28ac5ce03
BLAKE2b-256 d7ece51fdc309482cb2ae344e91cf0fefbdb469264aee6d6833b5839010aa1ca

See more details on using hashes here.

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