mirror of
https://github.com/RicterZ/nhentai.git
synced 2025-04-19 10:21:19 +02:00
fix #50
This commit is contained in:
parent
13e60a69e9
commit
8317662664
@ -97,7 +97,7 @@ def cmd_parser():
|
||||
logger.warning('YOU DO NOT SPECIFY `--download` OPTION !!!')
|
||||
|
||||
if args.id:
|
||||
_ = map(lambda id: id.strip(), args.id.split(','))
|
||||
_ = map(lambda id_: id_.strip(), args.id.split(','))
|
||||
args.id = set(map(int, filter(lambda id_: id_.isdigit(), _)))
|
||||
|
||||
if args.file:
|
||||
|
@ -70,7 +70,7 @@ def login_parser():
|
||||
count = html.find('span', attrs={'class': 'count'})
|
||||
if not count:
|
||||
logger.error("Can't get your number of favorited doujins. Did the login failed?")
|
||||
return
|
||||
return []
|
||||
|
||||
count = int(count.text.strip('(').strip(')').replace(',', ''))
|
||||
if count == 0:
|
||||
@ -94,7 +94,8 @@ def login_parser():
|
||||
def _callback(request, result):
|
||||
ret.append(result)
|
||||
|
||||
thread_pool = threadpool.ThreadPool(5)
|
||||
# TODO: reduce threads number ...
|
||||
thread_pool = threadpool.ThreadPool(3)
|
||||
|
||||
for page in range(1, pages + 1):
|
||||
try:
|
||||
@ -121,7 +122,14 @@ def doujinshi_parser(id_):
|
||||
url = '{0}/{1}/'.format(constant.DETAIL_URL, id_)
|
||||
|
||||
try:
|
||||
response = request('get', url).content
|
||||
response = request('get', url)
|
||||
if response.status_code in (200, ):
|
||||
response = response.content
|
||||
else:
|
||||
logger.debug('Slow down and retry ({}) ...'.format(id_))
|
||||
time.sleep(1)
|
||||
return doujinshi_parser(str(id_))
|
||||
|
||||
except Exception as e:
|
||||
logger.critical(str(e))
|
||||
raise SystemExit
|
||||
@ -333,3 +341,4 @@ def tag_parser(tag_name, max_page=1):
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(doujinshi_parser("32271"))
|
||||
eval
|
Loading…
x
Reference in New Issue
Block a user