Package: dev-nhentai-build
NHentai APIA NHentai API made using python webscrapping.For update notes follow me onTwitteror join on NHentai-APIdiscord serverInstallationpipinstall--upgradeNHentai-APIorpip3 install --upgrade NHentai-APILibrary FeaturesHome page pagination;Doujin information;Random doujin;Search;Comment Listing;Today's Popular Doujins.HomefromNHentaiimportNHentainhentai=NHentai()random_doujin:HomePage=nhentai.get_pages(page=1)The expected output is a HomePage instance:Page(doujins:List[Doujin(id:intmedia_id:strupload_at:datetimeurl:strtitle:List[Title]tags:List[Tag]artists:List[Tag]languages:List[Tag]categories:List[Tag]characters:List[Tag]parodies:List[Tag]groups:List[Tag]cover:Coverimages:List[DoujinPage]total_favorites:int=0total_pages:int=0)],total_pages:int,total_results:int,per_page:int)RandomfromNHentaiimportNHentainhentai=NHentai()random_doujin:Doujin=nhentai.get_random()The expected output is a Doujin instance:Doujin(id:intmedia_id:strupload_at:datetimeurl:strtitle:List[Title]tags:List[Tag]artists:List[Tag]languages:List[Tag]categories:List[Tag]characters:List[Tag]parodies:List[Tag]groups:List[Tag]cover:Coverimages:List[DoujinPage]total_favorites:int=0total_pages:int=0)Note: Not all doujins have certain properties liketags,artists, etc. They could be an empty list or a NoneType value.SearchfromNHentaiimportNHentai,Sortnhentai=NHentai()search_obj:SearchPage=nhentai.search(query='naruto',sort=Sort.RECENT,page=1)search_obj:SearchPage=nhentai.search(query='30955',page=1)The expected output is a SearchPage instance:SearchPage(query:strsort:strtotal_results:inttotal_pages:intdoujins:List[Doujin(id:intmedia_id:strupload_at:datetimeurl:strtitle:List[Title]tags:List[Tag]artists:List[Tag]languages:List[Tag]categories:List[Tag]characters:List[Tag]parodies:List[Tag]groups:List[Tag]cover:Coverimages:List[DoujinPage]total_favorites:int=0total_pages:int=0)])DoujinfromNHentaiimportNHentainhentai=NHentai()doujin:Doujin=nhentai.get_doujin(doujin_id=287167)The expected output is a Doujin instance:Doujin(id:intmedia_id:strupload_at:datetimeurl:strtitle:List[Title]tags:List[Tag]artists:List[Tag]languages:List[Tag]categories:List[Tag]characters:List[Tag]parodies:List[Tag]groups:List[Tag]cover:Coverimages:List[DoujinPage]total_favorites:int=0total_pages:int=0)CommentsfromNHentaiimportNHentainhentai=NHentai()comments:CommentPage=nhentai.get_comments(doujin_id=1)The expected output is a CharacterListPage instance:CommentPage(total_comments:intcomments:List[Comment(id:int,gallery_id:int,poster=User(id:int,username:str,slug:str,avatar_url:str,is_superuser:bool,is_staff:bool),post_date:str,body:str)])Most PopularfromNHentaiimportNHentainhentai=NHentai()doujins:PopularPage=nhentai.get_popular_now()The expected output is a PopularPage instance:PopularPage(total_doujins:intdoujins:List[Doujin(id:intmedia_id:strupload_at:datetimeurl:strtitle:List[Title]tags:List[Tag]artists:List[Tag]languages:List[Tag]categories:List[Tag]characters:List[Tag]parodies:List[Tag]groups:List[Tag]cover:Coverimages:List[DoujinPage]total_favorites:int=0total_pages:int=0)],)NHentai API AsyncThis is the first version of the asynchronous nhentai scrapper. The methods work in the very same way as the base nhentai scrapper, but to make it work you'll have to work with asyncio module using an event loop that you can import from it or get from NHentaiAsync class property:event_loop.Since we're working with async functions, you can only call the NHentaiAsync methods from inside an async funcion or context.
If you are already working in an async event loop, such as a python Discord API likediscord.py, you can simply await calls that you would otherwise have to callrun_until_completeon top of.Async example 1:fromNHentaiimportNHentaiAsyncnhentai_async=NHentaiAsync()event_loop=nhentai_async.event_looppopular=event_loop.run_until_complete(nhentai_async.get_popular_now())print(popular)Async example 2:fromNHentaiimportNHentaiAsyncnhentai_async=NHentaiAsync()asyncdefget_popular():popular=awaitnhentai_async.get_popular_now()print(popular)event_loop=nhentai_async.event_loopevent_loop.run_until_complete(get_popular())Await example:fromNHentaiimportNHentaiAsyncnhentai_async=NHentaiAsync()# Run in an async function or you will get an error: `'await' outside async function`.popular=awaitnhentai_async.get_popular_now()print(popular)