项目作者: hentai-chan

项目描述 :
Implements a wrapper class around nhentai's RESTful API.
高级语言: Python
项目地址: git://github.com/hentai-chan/hentai.git
创建时间: 2020-09-14T15:15:05Z
项目社区:https://github.com/hentai-chan/hentai

开源协议:GNU General Public License v3.0

下载







“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:

  1. pip install hentai --only-binary all

Dev Notes for Contributors

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

bash 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:

  1. from hentai import Hentai, Format
  2. doujin = Hentai(177013)
  3. # True
  4. Hentai.exists(doujin.id)
  5. # METAMORPHOSIS
  6. print(doujin.title(Format.Pretty))
  7. # [Tag(id=3981, type='artist', name='shindol', url='https://nhentai.net/artist/shindol/', count=279)]
  8. print(doujin.artist)
  9. # ['dark skin', 'group', ... ]
  10. print([tag.name for tag in doujin.tag])
  11. # 2016-10-18 12:28:49+00:00
  12. print(doujin.upload_date)
  13. # ['https://i.nhentai.net/galleries/987560/1.jpg', ... ]
  14. print(doujin.image_urls)
  15. # get the source
  16. doujin.download(progressbar=True)

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

  1. from hentai import Utils, Sort, Option, Tag
  2. from pathlib import Path
  3. print(Utils.get_random_id())
  4. # recommend me something good!
  5. print(Utils.get_random_hentai())
  6. # advanced search with queries
  7. for doujin in Utils.search_by_query('tag:loli', sort=Sort.PopularWeek):
  8. print(doujin.title(Format.Pretty))
  9. # print all character names from all doujins
  10. for character in Tag.list(Option.Character):
  11. print(character.name)
  12. # store custom meta data as JSON file to disk
  13. popular_loli = Utils.search_by_query('tag:loli', sort=Sort.PopularWeek)
  14. custom = [Option.ID, Option.Title, Option.Epos]
  15. 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:

  1. # get help
  2. hentai --help
  3. # download this doujin to the CWD
  4. hentai download --id 177013
  5. # check the module version
  6. hentai --version

Get In Touch

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