diff --git a/README.md b/README.md index d016e13..075e79a 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/doujinshi.txt b/doujinshi.txt new file mode 100644 index 0000000..ae794d6 --- /dev/null +++ b/doujinshi.txt @@ -0,0 +1,5 @@ +184212 +204944 +222460 +244502 +261909 diff --git a/nhentai/cmdline.py b/nhentai/cmdline.py index 1f4543d..e0dc84f 100644 --- a/nhentai/cmdline.py +++ b/nhentai/cmdline.py @@ -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')