From f44b9e99116f88f5fb8d347f3a7276073bc25c84 Mon Sep 17 00:00:00 2001 From: Ricter Z Date: Mon, 6 Feb 2023 17:12:10 +0800 Subject: [PATCH] add counter --- nhentai/parser.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/nhentai/parser.py b/nhentai/parser.py index 1b95334..1d8d7a6 100644 --- a/nhentai/parser.py +++ b/nhentai/parser.py @@ -112,6 +112,7 @@ def doujinshi_parser(id_): doujinshi = dict() doujinshi['id'] = id_ url = f'{constant.DETAIL_URL}/{id_}/' + counter = 0 try: response = request('get', url) @@ -121,6 +122,12 @@ def doujinshi_parser(id_): logger.error(f'Doujinshi with id {id_} cannot be found') return [] else: + counter += 1 + + if counter == 10: + logger.critical(f'Failed to fetch doujinshi information of id {id_}') + sys.exit(1) + logger.debug(f'Slow down and retry ({id_}) ...') time.sleep(1) return doujinshi_parser(str(id_))