From dd7b2d493e54185e30173e5a77161db0634977ba Mon Sep 17 00:00:00 2001 From: Ricter Z Date: Mon, 2 May 2016 16:03:28 +0800 Subject: [PATCH] fix bug of return value --- nhentai/cmdline.py | 6 +++--- nhentai/command.py | 2 +- nhentai/parser.py | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/nhentai/cmdline.py b/nhentai/cmdline.py index 8b6720c..826ea7d 100644 --- a/nhentai/cmdline.py +++ b/nhentai/cmdline.py @@ -46,20 +46,20 @@ def cmd_parser(): if args.is_download and not args.id and not args.ids and not args.keyword: logger.critical('Doujinshi id/ids is required for downloading') parser.print_help() - exit(1) + exit(0) if args.id: args.ids = (args.id, ) if not args.ids else args.ids if not args.keyword and not args.ids: parser.print_help() - exit(1) + exit(0) if args.threads <= 0: args.threads = 1 elif args.threads > 10: logger.critical('Maximum number of used threads is 10') - exit(1) + exit(0) if args.proxy: import urlparse diff --git a/nhentai/command.py b/nhentai/command.py index 4c05eea..b7df177 100644 --- a/nhentai/command.py +++ b/nhentai/command.py @@ -28,7 +28,7 @@ def main(): doujinshi_info = doujinshi_parser(id) doujinshi_list.append(Doujinshi(**doujinshi_info)) else: - exit(1) + exit(0) if options.is_download: downloader = Downloader(path=options.saved_path, diff --git a/nhentai/parser.py b/nhentai/parser.py index e9cb4c5..25bf785 100644 --- a/nhentai/parser.py +++ b/nhentai/parser.py @@ -1,6 +1,5 @@ # coding: utf-8 from __future__ import print_function -import sys import re import requests from bs4 import BeautifulSoup @@ -30,7 +29,7 @@ def doujinshi_parser(id_): response = request('get', url).content except Exception as e: logger.critical(str(e)) - sys.exit() + exit(1) html = BeautifulSoup(response) doujinshi_info = html.find('div', attrs={'id': 'info'}) @@ -45,7 +44,8 @@ def doujinshi_parser(id_): img_id = re.search('/galleries/([\d]+)/cover\.(jpg|png)$', doujinshi_cover.a.img['src']) if not img_id: logger.critical('Tried yo get image id failed') - sys.exit() + exit(1) + doujinshi['img_id'] = img_id.group(1) doujinshi['ext'] = img_id.group(2)