4
0
mirror of https://github.com/RicterZ/nhentai.git synced 2025-04-30 00:00:48 +02:00

Merge pull request from onlymyflower/master

download ids from file
This commit is contained in:
Ricter Zheng 2019-04-11 22:09:30 +08:00 committed by GitHub
commit c30f562a83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 1 deletions

@ -29,6 +29,11 @@ Download specified doujinshi:
nhentai --id=123855,123866
```
Download doujinshi with ids specified in a file:
```bash
nhentai --file=doujinshi.txt
```
Search a keyword and download the first page:
```bash
nhentai --search="tomori" --page=1 --download

5
doujinshi.txt Normal file

@ -0,0 +1,5 @@
184212
204944
222460
244502
261909

@ -37,6 +37,7 @@ def banner():
def cmd_parser():
parser = OptionParser('\n nhentai --search [keyword] --download'
'\n NHENTAI=http://h.loli.club nhentai --id [ID ...]'
'\n nhentai --file [filename]'
'\n\nEnvironment Variable:\n'
' NHENTAI nhentai mirror url')
parser.add_option('--download', dest='is_download', action='store_true',
@ -70,7 +71,8 @@ def cmd_parser():
help='Generate Comic Book CBZ File')
parser.add_option('--rm-origin-dir', dest='rm_origin_dir', action='store_true', default=False,
help='Remove downloaded doujinshi dir when generated CBZ file.')
parser.add_option('--file', '-f', type='string', dest='file', action='store', help='Read gallery IDs from file.')
try:
sys.argv = list(map(lambda x: unicode(x.decode(sys.stdin.encoding)), sys.argv))
except (NameError, TypeError):
@ -98,6 +100,11 @@ def cmd_parser():
_ = map(lambda id: id.strip(), args.id.split(','))
args.id = set(map(int, filter(lambda id_: id_.isdigit(), _)))
if args.file:
with open(args.file, 'r') as f:
_ = map(lambda id: id.strip(), f.readlines())
args.id = set(map(int, filter(lambda id_: id_.isdigit(), _)))
if (args.is_download or args.is_show) and not args.id and not args.keyword and \
not args.login and not args.tag:
logger.critical('Doujinshi id(s) are required for downloading')