• Stars
    star
    773
  • Rank 58,400 (Top 2 %)
  • Language
    Python
  • License
    MIT License
  • Created over 9 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

nhentai doujinshi downloader

nhentai

あなたも変態。 いいね?

travis pypi version license

nhentai is a CLI tool for downloading doujinshi from nhentai.net

Manual Installation

From Github:

git clone https://github.com/RicterZ/nhentai
cd nhentai
python setup.py install

Build Docker container:

git clone https://github.com/RicterZ/nhentai
cd nhentai
docker build -t nhentai:latest .
docker run --rm -it -v ~/Downloads/doujinshi:/output -v ~/.nhentai/:/root/.nhentai nhentai --id 123855

Installation

From PyPI with pip:

pip install nhentai

For a self-contained installation, use pipx:

pipx install nhentai

Pull from Dockerhub:

docker pull ricterz/nhentai
docker run --rm -it -v ~/Downloads/doujinshi:/output -v ~/.nhentai/:/root/.nhentai ricterz/nhentai --id 123855

On Gentoo Linux:

layman -fa glicOne
sudo emerge net-misc/nhentai

On NixOS:

nix-env -iA nixos.nhentai

Usage

⚠️IMPORTANT⚠️: To bypass the nhentai frequency limit, you should use --cookie and --useragent options to store your cookie and your user-agent.

nhentai --useragent "USER AGENT of YOUR BROWSER"
nhentai --cookie "YOUR COOKIE FROM nhentai.net"

NOTE:

  • The format of the cookie is "csrftoken=TOKEN; sessionid=ID; cf_clearance=CLOUDFLARE"
  • cf_clearance cookie and useragent must be set if you encounter "blocked by cloudflare captcha" error. Make sure you use the same IP and useragent as when you got it
To get csrftoken and sessionid, first login to your nhentai account in web browser, then:
(Chrome) ⋮ — More tools — Developer tools — Application — Storage — Cookies — https://nhentai.net
(Firefox) ☰ — Web Developer — Web Developer Tools — Storage — Cookies — https://nhentai.net

nhentai

The default download folder will be the path where you run the command (%cd% or $PWD).

Download specified doujinshi:

nhentai --id 123855 123866 123877

Download doujinshi with ids specified in a file (doujinshi ids split by line):

nhentai --file=doujinshi.txt

Set search default language

nhentai --language=english

Search a keyword and download the first page:

nhentai --search="tomori" --page=1 --download
# you also can download by tags and multiple keywords
nhentai --search="tag:lolicon, artist:henreader, tag:full color"
nhentai --search="lolicon, henreader, full color"

Download your favorites with delay:

nhentai --favorites --download --delay 1

Format output doujinshi folder name:

nhentai --id 261100 --format '[%i]%s'

Supported doujinshi folder formatter:

  • %i: Doujinshi id
  • %t: Doujinshi name
  • %s: Doujinshi subtitle (translated name)
  • %a: Doujinshi authors' name
  • %g: Doujinshi groups name
  • %p: Doujinshi pretty name
  • %ag: Doujinshi authors name or groups name

Other options:

Usage:
  nhentai --search [keyword] --download
  NHENTAI=https://nhentai-mirror-url/ nhentai --id [ID ...]
  nhentai --file [filename]

Environment Variable:
  NHENTAI                 nhentai mirror url

Options:
  # Operation options, control the program behaviors
  -h, --help            show this help message and exit
  -D, --download        download doujinshi (for search results)
  -S, --show            just show the doujinshi information

  # Doujinshi options, specify id, keyword, etc.
  --id                  doujinshi ids set, e.g. 167680 167681 167682
  -s KEYWORD, --search=KEYWORD
                        search doujinshi by keyword
  -F, --favorites       list or download your favorites

  # Page options, control the page to fetch / download
  --page-all            all search results
  --page=PAGE, --page-range=PAGE
                        page number of search results. e.g. 1,2-5,14
  --sorting=SORTING     sorting of doujinshi (recent / popular /
                        popular-[today|week])

  # Download options, the output directory, threads, timeout, delay, etc.
  -o OUTPUT_DIR, --output=OUTPUT_DIR
                        output dir
  -t THREADS, --threads=THREADS
                        thread count for downloading doujinshi
  -T TIMEOUT, --timeout=TIMEOUT
                        timeout for downloading doujinshi
  -d DELAY, --delay=DELAY
                        slow down between downloading every doujinshi
  --proxy=PROXY         store a proxy, for example: -p "http://127.0.0.1:1080"
  -f FILE, --file=FILE  read gallery IDs from file.
  --format=NAME_FORMAT  format the saved folder name
  --dry-run             Dry run, skip file download

  # Generate options, for generate html viewer, cbz file, pdf file, etc
  --html                generate a html viewer at current directory
  --no-html             don't generate HTML after downloading
  --gen-main            generate a main viewer contain all the doujin in the
                        folder
  -C, --cbz             generate Comic Book CBZ File
  -P, --pdf             generate PDF file
  --rm-origin-dir       remove downloaded doujinshi dir when generated CBZ or
                        PDF file
  --meta                generate a metadata file in doujinshi format
  --regenerate-cbz      regenerate the cbz file if exists

  # nhentai options, set cookie, user-agent, language, remove caches, histories, etc
  --cookie=COOKIE       set cookie of nhentai to bypass Cloudflare captcha
  --useragent=USERAGENT, --user-agent=USERAGENT
                        set useragent to bypass Cloudflare captcha
  --language=LANGUAGE   set default language to parse doujinshis
  --clean-language      set DEFAULT as language to parse doujinshis
  --save-download-history
                        save downloaded doujinshis, whose will be skipped if
                        you re-download them
  --clean-download-history
                        clean download history
  --template=VIEWER_TEMPLATE
                        set viewer template
  --legacy              use legacy searching method

nHentai Mirror

If you want to use a mirror, you should set up a reverse proxy of nhentai.net and i.nhentai.net. For example:

i.h.loli.club -> i.nhentai.net
h.loli.club -> nhentai.net

Set NHENTAI env var to your nhentai mirror.

NHENTAI=https://h.loli.club nhentai --id 123456

nhentai

nhentai

nhentai

More Repositories

1

genpAss

Python
754
star
2

BGmi

BGmi is a cli tool for subscribed bangumi.
386
star
3

PySharpSphere

Yet another SharpSphere
Python
219
star
4

CVE-2021-3560-Authentication-Agent

PolicyKit CVE-2021-3560 Exploit (Authentication Agent)
Go
113
star
5

shell-blog

My blog
Shell
70
star
6

My-NSE-Scripts

My NSE Scripts
Lua
62
star
7

reprocks

A python socks5 proxy server/client
Python
59
star
8

pyprint

A simple blog system which just for me
JavaScript
59
star
9

riXSS

A Open Source XSS test platform powered by web.py <img/src=1 onerror=alert/:P/
Python
38
star
10

unserchain

PHP
34
star
11

AnimeReminder

Anime Reminder
Python
33
star
12

zabbixPwn

Zabbix Jsrpc.php Injection Exploit
Python
25
star
13

scastpy

A simple screencast receiver written by Python
Python
24
star
14

aria2-ios

Aria2 iOS Client
Swift
24
star
15

simple-dns

A simple regular-expression based DNS server
Python
23
star
16

zhihu.daily.rss

知乎日报RSS版
Python
22
star
17

nichijou

Just a Simple Node.js+AngularJs Blog system
JavaScript
19
star
18

biubiubiu

网页弹幕www
JavaScript
10
star
19

angular-duoshuo

A AngularJS plugin for duoshuo
8
star
20

PIE-Stack-Clash-CVE-2017-1000253

Demo-ing CVE-2017-1000253 in a container
C
5
star
21

RicBlog

(Stop Update)RicBlog is a lightweight blog system.
Python
4
star
22

kotlin-koans

Kotlin
4
star
23

rss.ricterz.me

RSS crawlers and server
Python
3
star
24

moescan

Auxiliary scanner for pentesting
Python
3
star
25

simpleLogin

Mongodb Injection test
JavaScript
2
star
26

llRedio

一个Django框架下的在线听歌平台。
Python
2
star
27

PiHome

Python
2
star
28

wolai-python

Unofficial wolai python SDK
Python
1
star
29

circle

Just a simple chat room
Python
1
star
30

pbox

A django+django rest framework bbs
Python
1
star
31

rixb-theme-light

A rixb theme
CSS
1
star
32

cloudtree

JavaScript
1
star
33

SinaFMDownloader

SinaMicroFMDownloader
Python
1
star