Package: nhentei
Introduction to nhenteiAbout:Short: nhentei is a python implementation of nHentai's API.
Why: Because nHentai's documentation of their API is really...short. That's why nhentei exists.
nhentei is an asynchronous library, keep that in mind.Required packages:Following packages will be installed too when pip installing nhentei:aiohttprequestsasyncioMade in python 3Getting started:Install nhentei via pip:pip install nhenteiIf you do not have pip installed, get pip first.
To use it in your project, putfrom nhentei import nfunctionsat the top of your python file.
We'll refer to the commands withnfunctions.*functionName()*laterBasic example:nhentei basically consists out of utility functions containing direct API requests.from nhentei import nfunctions
#Get a dictionary containing metadata:
dict = await nfunctions.getByID("1")
#This will return a dictionary containing all data of hentai with ID 1
pages = dict['num_pages']
#pages now contains the number of pages the hentai hasHentai dictionaries: What do they store?You will find a list of keys you can use to get data from the dictionary below:keydescriptionidunique nhentai identifier, starting from 1media_idused to get images or mediatitlereturns a dictionary (more to that later)imagesreturns a dictionary (more to that later)scanlatorname of the scanlatorupload_datedate in unix timestamp format)tagsreturns an array of tags(more to that later)num_pagesnumber of pagesnum_favoritesnumber of favorites"title" dictionaryThe returned dictionary for the key "title" contains following keys:"english" --> Returns the title in english (string)(always exists)
"japanese" --> Returns the title in japanese (string)(not guaranteed to exist)
"pretty" --> Returns the title in a pretty format (string)(not guaranteed to exist)"images" dictionaryThe returned dictionary for the key "images" contains following keys:"pages"--> Returns an array containing dictionaries, if the hentai has
	    14 pages, the array will go from 0-13.
	    Every dictionary contains following keys:
	    "t" --> returns a single char
	    "w" --> returns the width of the image
	    "h" --> returns the height of the image
"cover"-->This dictionary contains following keys:
	    "t" --> returns a single char
	    "w" --> returns the width of the image
	    "h" --> returns the height of the image
"thumbnail"-->This dictionary contains following keys:
	    "t" --> returns a single char
	    "w" --> returns the width of the image
	    "h" --> returns the height of the image"tags" array / listEvery array slot / list slot contains a dictionary representing a "tag",
it has following keys:"id" --> Identifier for the tag
"type" --> Returns tag type: can be either "artist", "tag", "group", "parody", "character", "language", "category"
"name" --> Depends on the "type": for artists, this will be the name of the artist, for tag it will be the name of the tag.
"url" --> the payload url
"count" --> number of hentai with this tag/artist/etc.Functions:getByID(id)parameter nametypereturnsidStringDictionary containing hentai metadataThis function will return the above explained dictionary by giving it an IDgetByTags(tags,page,sort,  num)Takes parameters:tags(String format, separated by commas) The tags you want to search withpage(int format)(optional, defaults to 1) The result page to getsort(String format)(optional, defaults to "popular") The sorting algorithmnum(int format)(optional, defaults to "popular") The number of entriesReturns:list -- Contains dictionaries with hentai with the tagsgetPayloadSearch(payload)Takes parameters:payload(In string format, more to payloads soon)Returns: dictionarygetByTitle(title,page,sort)Takes parameters:tags(String format, separated by commas)page(integer format)(optional, defaults to 1)sort(String format)(optional, defaults to "popular")Returns:list -- Contains dictionary of hentai with the titlegetByCharacter(character,page,sort)Takes parameters:character(String format, separated by commas)page(integer format)(optional, defaults to 1)sort(String format)(optional, defaults to "popular")Returns:list -- Contains dictionary of hentai with the character(s)getByParody(title,page,sort)Takes parameters:title(String format, separated by commas)page(integer format)(optional, defaults to 1)sort(String format)(optional, defaults to "popular")Returns:list -- Contains dictionary of hentai that are a parody of the titlegetCover(media_id)Takes parameters:media_id(String format, separated by commas)Returns:url to the source imagegetPageImage(media_id, page)Takes parameters:media_id(String format, separated by commas)page(String format, separated by commas) The page of the hentai, starts with 0Returns:url to the source imageCredits to:EpicGamer for crawling through API outputsnhentai.netfor the API and art