fix bug of return value

This commit is contained in:
Ricter Z 2016-05-02 16:03:28 +08:00
parent 3d481dbf13
commit dd7b2d493e
3 changed files with 7 additions and 7 deletions

View File

@ -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

View File

@ -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,

View File

@ -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)