2 from optparse import OptionParser
3 from itertools import ifilter
4 from logger import logger
9 _ __ | | | | ___ _ __ | |_ __ _(_)
10 | '_ \| |_| |/ _ \ '_ \| __/ _` | |
11 | | | | _ | __/ | | | || (_| | |
12 |_| |_|_| |_|\___|_| |_|\__\__,_|_|
17 parser = OptionParser()
18 parser.add_option('--download', dest='is_download', action='store_true', help='download dojinshi or not')
19 parser.add_option('--id', type='int', dest='id', action='store', help='dojinshi id of nhentai')
20 parser.add_option('--ids', type='str', dest='ids', action='store', help='dojinshi id set, e.g. 1,2,3')
21 parser.add_option('--search', type='string', dest='keyword', action='store', help='keyword searched')
22 parser.add_option('--page', type='int', dest='page', action='store', default=1,
23 help='page number of search result')
24 parser.add_option('--path', type='string', dest='saved_path', action='store', default='',
25 help='path which save the dojinshi')
26 parser.add_option('--threads', '-t', type='int', dest='threads', action='store', default=1,
27 help='thread count of download dojinshi')
28 args, _ = parser.parse_args()
31 _ = map(lambda id: id.strip(), args.ids.split(','))
32 args.ids = set(map(int, ifilter(lambda id: id.isdigit(), _)))
34 if args.is_download and not args.id and not args.ids and not args.keyword:
35 logger.critical('Dojinshi id/ids is required for downloading')
40 args.ids = (args.id, ) if not args.ids else args.ids
42 if not args.keyword and not args.ids:
48 elif args.threads > 10:
49 logger.critical('Maximum number of used threads is 10')