mirror of
https://github.com/RicterZ/nhentai.git
synced 2025-04-20 02:41:19 +02:00
change the way of download
This commit is contained in:
parent
e42f42d7db
commit
3eacd118ed
@ -21,13 +21,13 @@ nhentai
|
|||||||
+ 下载指定 id 的本子:
|
+ 下载指定 id 的本子:
|
||||||
|
|
||||||
|
|
||||||
nhentai --id=123855 --download
|
nhentai --id=123855
|
||||||
|
|
||||||
|
|
||||||
+ 下载指定 id 列表的本子:
|
+ 下载指定 id 列表的本子:
|
||||||
|
|
||||||
|
|
||||||
nhentai --ids=123855,123866 --download
|
nhentai --ids=123855,123866
|
||||||
|
|
||||||
|
|
||||||
+ 下载某关键词第一页的本子(不推荐):
|
+ 下载某关键词第一页的本子(不推荐):
|
||||||
|
@ -23,13 +23,12 @@ def banner():
|
|||||||
def cmd_parser():
|
def cmd_parser():
|
||||||
parser = OptionParser()
|
parser = OptionParser()
|
||||||
parser.add_option('--download', dest='is_download', action='store_true', help='download doujinshi or not')
|
parser.add_option('--download', dest='is_download', action='store_true', help='download doujinshi or not')
|
||||||
parser.add_option('--id', type='int', dest='id', action='store', help='doujinshi id of nhentai')
|
parser.add_option('--id', type='str', dest='id', action='store', help='doujinshi ids set, e.g. 1,2,3')
|
||||||
parser.add_option('--ids', type='str', dest='ids', action='store', help='doujinshi id set, e.g. 1,2,3')
|
|
||||||
parser.add_option('--search', type='string', dest='keyword', action='store', help='keyword searched')
|
parser.add_option('--search', type='string', dest='keyword', action='store', help='keyword searched')
|
||||||
parser.add_option('--page', type='int', dest='page', action='store', default=1,
|
parser.add_option('--page', type='int', dest='page', action='store', default=1,
|
||||||
help='page number of search result')
|
help='page number of search result')
|
||||||
parser.add_option('--path', type='string', dest='saved_path', action='store', default='',
|
parser.add_option('--output', type='string', dest='output_dir', action='store', default='',
|
||||||
help='path which save the doujinshi')
|
help='output dir')
|
||||||
parser.add_option('--threads', '-t', type='int', dest='threads', action='store', default=5,
|
parser.add_option('--threads', '-t', type='int', dest='threads', action='store', default=5,
|
||||||
help='thread count of download doujinshi')
|
help='thread count of download doujinshi')
|
||||||
parser.add_option('--timeout', type='int', dest='timeout', action='store', default=30,
|
parser.add_option('--timeout', type='int', dest='timeout', action='store', default=30,
|
||||||
@ -38,24 +37,22 @@ def cmd_parser():
|
|||||||
help='use proxy, example: http://127.0.0.1:1080')
|
help='use proxy, example: http://127.0.0.1:1080')
|
||||||
args, _ = parser.parse_args()
|
args, _ = parser.parse_args()
|
||||||
|
|
||||||
if args.ids:
|
if args.id:
|
||||||
_ = map(lambda id: id.strip(), args.ids.split(','))
|
_ = map(lambda id: id.strip(), args.id.split(','))
|
||||||
args.ids = set(map(int, filter(lambda id: id.isdigit(), _)))
|
args.id = set(map(int, filter(lambda id: id.isdigit(), _)))
|
||||||
|
|
||||||
if args.is_download and not args.id and not args.ids and not args.keyword:
|
if args.is_download and not args.id and not args.keyword:
|
||||||
logger.critical('Doujinshi id/ids is required for downloading')
|
logger.critical('Doujinshi id(s) are required for downloading')
|
||||||
parser.print_help()
|
parser.print_help()
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
if args.id:
|
if not args.keyword and not args.id:
|
||||||
args.ids = (args.id, ) if not args.ids else args.ids
|
|
||||||
|
|
||||||
if not args.keyword and not args.ids:
|
|
||||||
parser.print_help()
|
parser.print_help()
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
if args.threads <= 0:
|
if args.threads <= 0:
|
||||||
args.threads = 1
|
args.threads = 1
|
||||||
|
|
||||||
elif args.threads > 10:
|
elif args.threads > 10:
|
||||||
logger.critical('Maximum number of used threads is 10')
|
logger.critical('Maximum number of used threads is 10')
|
||||||
exit(0)
|
exit(0)
|
||||||
|
@ -22,7 +22,7 @@ def main():
|
|||||||
if options.is_download:
|
if options.is_download:
|
||||||
doujinshi_ids = map(lambda d: d['id'], doujinshis)
|
doujinshi_ids = map(lambda d: d['id'], doujinshis)
|
||||||
else:
|
else:
|
||||||
doujinshi_ids = options.ids
|
doujinshi_ids = options.id
|
||||||
|
|
||||||
if doujinshi_ids:
|
if doujinshi_ids:
|
||||||
for id in doujinshi_ids:
|
for id in doujinshi_ids:
|
||||||
@ -31,14 +31,11 @@ def main():
|
|||||||
else:
|
else:
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
if options.is_download:
|
downloader = Downloader(path=options.output_dir,
|
||||||
downloader = Downloader(path=options.saved_path,
|
thread=options.threads, timeout=options.timeout)
|
||||||
thread=options.threads, timeout=options.timeout)
|
for doujinshi in doujinshi_list:
|
||||||
for doujinshi in doujinshi_list:
|
doujinshi.downloader = downloader
|
||||||
doujinshi.downloader = downloader
|
doujinshi.download()
|
||||||
doujinshi.download()
|
|
||||||
else:
|
|
||||||
map(lambda doujinshi: doujinshi.show(), doujinshi_list)
|
|
||||||
|
|
||||||
logger.log(15, u'🍺 All done.')
|
logger.log(15, u'🍺 All done.')
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user