Giter VIP home page Giter VIP logo

nhentai-ts's Introduction

nhentai-ts

NPM

Scrap and build a PDF of a doujin from NHentai. Check the available sites here.

Documentation


Installation

yarn add @shineiichijo/nhentai-ts

Note

If you're choosing nhentai.net for the site, make sure to follow the following steps (as the site has enabled cloudflare protection):

  • Open https://nhentai.net/ in your browser.
  • Open Dev Tools and set the User Agent to what you want (you'll need the user agent).
  • Reload the site and wait for the clearance of cloudflare (without closing the Dev Tools).
  • Save the cookie value from the Network Tab (cf_clearance value).

After following all these steps, you are all set. You can also check the example of it (at the first one). Remember, the cookie value expires after 30 minutes of inactivity. So, you might have to do the above steps again (in case you're gonna use it again).

Usage Examples

import { NHentai } from '@shineiichijo/nhentai-ts'

const user_agent = 'User Agent'
const cookie_value = 'cf_clearance=abcdefghijklmnopq'
const nhentai = new NHentai({ site: 'nhentai.net', user_agent, cookie_value }) //check above
;(async () => {
    //Explores the home page
    const { data } = await nhentai.explore()
    console.log(data)
})()
import { NHentai } from '@shineiichijo/nhentai-ts'

const nhentai = new NHentai()
;(async () => {
    //searches for manga
    const { data } = await nhentai.search('loli' /* title of the doujin to search */, { page: 1 } /* Page of the search */)
    const doujin = data[0]
    //gets the contents of a doujin
    const { images } = await doujin.getContents()
    console.log(images.pages) //pages of the doujin
    //builds a PDF from the doujin pages
    await images.PDF('loli.pdf' /* Filename of where the PDF should be saved */) //will return a Buffer if no filename is provided
})()
import { NHentai } from '@shineiichijo/nhentai-ts'

const nhentai = new NHentai({ site: 'nhentai.to' }) //configuring a mirror site of the class (you can check the available sites here: https://github.com/LuckyYam/nhentai-ts/blob/master/src/lib/constants.ts#L1)
//validates the ID of a doujin
nhentai.validate('172').then(console.log)
import { NHentai } from '@shineiichijo/nhentai-ts'

const nhentai = new NHentai()
//explores all of the available doujin (homepage)
nhentai.explore(2 /* Page number of exploring the doujin */).then(console.log)
import { NHentai } from '@shineiichijo/nhentai-ts'

const nhentai = new NHentai()
//gets a random doujin with its contents
nhentai.getRandom().then(console.log)
import { NHentai } from '@shineiichijo/nhentai-ts'

const nhentai = new NHentai()
//gets a doujin contents by its ID
nhentai.getDoujin(172).then(console.log)
import { NHentai } from '@shineiichijo/nhentai-ts'

const nhentai = new NHentai()
nhentai.getDoujin('2456').then(
    async (res) =>
        //downloads the pages of a doujin and saves it in a folder
        await res.images.download(
            'nhentai' /* Folder name where the downloaded pages should be saved */
        )
)
import { NHentai } from '@shineiichijo/nhentai-ts'

const nhentai = new NHentai()
nhentai.getRandom().then(
    async (res) =>
        //Builds a zip of doujin pages
        await res.images.zip(
            'nhentai.zip' /* Filname of where the zip should be saved */
        ) //it will return a Buffer if no filename is provided
)

nhentai-ts's People

Contributors

aliaryantech avatar luckyyam avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

nhentai-ts's Issues

TypeError: NHentai is not a constructor

Hello, can someone help me solve this problem...

I tried using the package, installed via npm i @shineiichijo/nhentai-ts
Code i write:

let NHentai = require("@shineiichijo/nhentai-ts")

let nhentai = new NHentai();

(async () => {
    const { data } = await nhentai.search('loli' , { page: 1 });
    console.log(data);
})()

It returns error:

let nhentai = new NHentai();
              ^

TypeError: NHentai is not a constructor
    at Object.<anonymous> (some path to file.js)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47

Node.js v18.17.0
Thanks

IMPORTANT

bro you bot - CHITOGE
please make it work again there are no bot like that
( idk how to contact you so i came here )

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.