mirror of
https://github.com/RicterZ/nhentai.git
synced 2025-04-20 11:01:17 +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 !!!')
|
logger.warning('YOU DO NOT SPECIFY `--download` OPTION !!!')
|
||||||
|
|
||||||
if args.id:
|
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(), _)))
|
args.id = set(map(int, filter(lambda id_: id_.isdigit(), _)))
|
||||||
|
|
||||||
if args.file:
|
if args.file:
|
||||||
|
@ -70,7 +70,7 @@ def login_parser():
|
|||||||
count = html.find('span', attrs={'class': 'count'})
|
count = html.find('span', attrs={'class': 'count'})
|
||||||
if not count:
|
if not count:
|
||||||
logger.error("Can't get your number of favorited doujins. Did the login failed?")
|
logger.error("Can't get your number of favorited doujins. Did the login failed?")
|
||||||
return
|
return []
|
||||||
|
|
||||||
count = int(count.text.strip('(').strip(')').replace(',', ''))
|
count = int(count.text.strip('(').strip(')').replace(',', ''))
|
||||||
if count == 0:
|
if count == 0:
|
||||||
@ -94,7 +94,8 @@ def login_parser():
|
|||||||
def _callback(request, result):
|
def _callback(request, result):
|
||||||
ret.append(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):
|
for page in range(1, pages + 1):
|
||||||
try:
|
try:
|
||||||
@ -121,7 +122,14 @@ def doujinshi_parser(id_):
|
|||||||
url = '{0}/{1}/'.format(constant.DETAIL_URL, id_)
|
url = '{0}/{1}/'.format(constant.DETAIL_URL, id_)
|
||||||
|
|
||||||
try:
|
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:
|
except Exception as e:
|
||||||
logger.critical(str(e))
|
logger.critical(str(e))
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
@ -333,3 +341,4 @@ def tag_parser(tag_name, max_page=1):
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
print(doujinshi_parser("32271"))
|
print(doujinshi_parser("32271"))
|
||||||
|
eval
|
Loading…
x
Reference in New Issue
Block a user