From 8546b9e759aa7a8685762d1a642ad8e4cd61564d Mon Sep 17 00:00:00 2001 From: Ricter Z Date: Sat, 11 Aug 2018 09:17:05 +0800 Subject: [PATCH] fix bug #24 --- nhentai/parser.py | 14 +++++++++++--- requirements.txt | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/nhentai/parser.py b/nhentai/parser.py index 6e9e117..bef5730 100644 --- a/nhentai/parser.py +++ b/nhentai/parser.py @@ -50,8 +50,16 @@ def login_parser(username, password): logger.error('Cannot get count of your favorites, maybe login failed.') count = int(count.text.strip('(').strip(')')) - pages = count / 25 - pages += 1 if count % (25 * pages) else 0 + if count == 0: + logger.warning('No favorites found') + return [] + pages = int(count / 25) + + if pages: + pages += 1 if count % (25 * pages) else 0 + else: + pages = 1 + logger.info('Your have %d favorites in %d pages.' % (count, pages)) if os.getenv('DEBUG'): @@ -68,7 +76,7 @@ def login_parser(username, password): for page in range(1, pages+1): try: logger.info('Getting doujinshi id of page %d' % page) - resp = s.get(constant.FAV_URL + '?page=%d' % page).content + resp = s.get(constant.FAV_URL + '?page=%d' % page).text ids = doujinshi_id.findall(resp) requests_ = threadpool.makeRequests(doujinshi_parser, ids, _callback) [thread_pool.putRequest(req) for req in requests_] diff --git a/requirements.txt b/requirements.txt index df0a2ee..4d3920e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,4 +2,4 @@ requests>=2.5.0 BeautifulSoup4>=4.0.0 threadpool>=1.2.7 tabulate>=0.7.5 -future>=0.15.2 \ No newline at end of file +future>=0.15.2threadpool==1.3.2