7 _ __ | | | | ___ _ __ | |_ __ _(_)
8 | '_ \| |_| |/ _ \ '_ \| __/ _` | |
9 | | | | _ | __/ | | | || (_| | |
10 |_| |_|_| |_|\___|_| |_|\__\__,_|_|
20 nHentai is a CLI tool for downloading doujinshi from <http://nhentai.net>
27 git clone https://github.com/RicterZ/nhentai
29 python setup.py install
34 Alternatively, install from PyPI with pip:
40 For a self-contained installation, use `Pipx <https://github.com/pipxproject/pipx/>`_:
52 sudo emerge net-misc/nhentai
59 nix-env -iA nixos.nhentai
64 **IMPORTANT**: To bypass the nhentai frequency limit, you should use `--cookie` option to store your cookie.
66 *The default download folder will be the path where you run the command (CLI path).*
69 Set your nhentai cookie against captcha:
73 nhentai --cookie "YOUR COOKIE FROM nhentai.net"
77 - The format of the cookie is `"csrftoken=TOKEN; sessionid=ID; cf_clearance=CLOUDFLARE"`
78 - `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
80 | To get csrftoken and sessionid, first login to your nhentai account in web browser, then:
81 | (Chrome) |ve| |ld| More tools |ld| Developer tools |ld| Application |ld| Storage |ld| Cookies |ld| https://nhentai.net
82 | (Firefox) |hv| |ld| Web Developer |ld| Web Developer Tools |ld| Storage |ld| Cookies |ld| https://nhentai.net
85 .. |hv| unicode:: U+2630 .. https://www.compart.com/en/unicode/U+2630
86 .. |ve| unicode:: U+22EE .. https://www.compart.com/en/unicode/U+22EE
87 .. |ld| unicode:: U+2014 .. https://www.compart.com/en/unicode/U+2014
89 Download specified doujinshi:
93 nhentai --id=123855,123866
95 Download doujinshi with ids specified in a file (doujinshi ids split by line):
99 nhentai --file=doujinshi.txt
101 Set search default language
105 nhentai --language=english
107 Search a keyword and download the first page:
111 nhentai --search="tomori" --page=1 --download
112 # you also can download by tags and multiple keywords
113 nhentai --search="tag:lolicon, artist:henreader, tag:full color"
114 nhentai --search="lolicon, henreader, full color"
116 Download your favorites with delay:
120 nhentai --favorites --download --delay 1
122 Format output doujinshi folder name:
126 nhentai --id 261100 --format '[%i]%s'
128 Supported doujinshi folder formatter:
132 - %s: Doujinshi subtitle (translated name)
133 - %a: Doujinshi authors' name
134 - %p: Doujinshi pretty name
142 nhentai --search [keyword] --download
143 NHENTAI=http://h.loli.club nhentai --id [ID ...]
144 nhentai --file [filename]
146 Environment Variable:
147 NHENTAI nhentai mirror url
150 # Operation options, control the program behaviors
151 -h, --help show this help message and exit
152 -D, --download download doujinshi (for search results)
153 -S, --show just show the doujinshi information
155 # Doujinshi options, specify id, keyword, etc.
156 --id=ID doujinshi ids set, e.g. 1,2,3
157 -s KEYWORD, --search=KEYWORD
158 search doujinshi by keyword
159 -F, --favorites list or download your favorites.
161 # Page options, control the page to fetch / download
162 --page-all all search results
163 --page=PAGE, --page-range=PAGE
164 page number of search results. e.g. 1,2-5,14
165 --sorting=SORTING sorting of doujinshi (recent / popular /
166 popular-[today|week])
168 # Download options, the output directory, threads, timeout, delay, etc.
169 -o OUTPUT_DIR, --output=OUTPUT_DIR
171 -t THREADS, --threads=THREADS
172 thread count for downloading doujinshi
173 -T TIMEOUT, --timeout=TIMEOUT
174 timeout for downloading doujinshi
175 -d DELAY, --delay=DELAY
176 slow down between downloading every doujinshi
177 --proxy=PROXY store a proxy, for example: -p 'http://127.0.0.1:1080'
178 -f FILE, --file=FILE read gallery IDs from file.
179 --format=NAME_FORMAT format the saved folder name
180 -r, --dry-run Dry run, skip file download.
182 # Generate options, for generate html viewer, cbz file, pdf file, etc
183 --html generate a html viewer at current directory
184 --no-html don't generate HTML after downloading
185 --gen-main generate a main viewer contain all the doujin in the
187 -C, --cbz generate Comic Book CBZ File
188 -P, --pdf generate PDF file
189 --rm-origin-dir remove downloaded doujinshi dir when generated CBZ or
191 --meta generate a metadata file in doujinshi format
192 --regenerate-cbz regenerate the cbz file if exists
194 # nhentai options, set cookie, user-agent, language, remove caches, histories, etc
195 --cookie=COOKIE set cookie of nhentai to bypass Cloudflare captcha
196 --useragent=USERAGENT
197 set useragent to bypass Cloudflare captcha
198 --language=LANGUAGE set default language to parse doujinshis
199 --clean-language set DEFAULT as language to parse doujinshis
200 --save-download-history
201 save downloaded doujinshis, whose will be skipped if
203 --clean-download-history
204 clean download history
205 --template=VIEWER_TEMPLATE
211 If you want to use a mirror, you should set up a reverse proxy of `nhentai.net` and `i.nhentai.net`.
216 i.h.loli.club -> i.nhentai.net
217 h.loli.club -> nhentai.net
219 Set `NHENTAI` env var to your nhentai mirror.
223 NHENTAI=http://h.loli.club nhentai --id 123456
226 .. image:: ./images/search.png?raw=true
229 .. image:: ./images/download.png?raw=true
232 .. image:: ./images/viewer.png?raw=true
238 .. |travis| image:: https://travis-ci.org/RicterZ/nhentai.svg?branch=master
239 :target: https://travis-ci.org/RicterZ/nhentai
241 .. |pypi| image:: https://img.shields.io/pypi/dm/nhentai.svg
242 :target: https://pypi.org/project/nhentai/
244 .. |license| image:: https://img.shields.io/github/license/ricterz/nhentai.svg
245 :target: https://github.com/RicterZ/nhentai/blob/master/LICENSE