mirror of
https://github.com/RicterZ/nhentai.git
synced 2025-04-19 18:31:24 +02:00
commit
179852a343
@ -17,9 +17,12 @@ jobs:
|
|||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
environment: nhentai_test
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
- name: Set env
|
||||||
|
run: |
|
||||||
|
echo "NHENTAI_COOKIE=csrftoken=zV4qotZJrHKTeEc9uEg5uvXV5qwTcZIHRjF3TgbkvP6OoxZNj8I6RFQeGSSiZT04; sessionid=t2x0ke3u5i1azg2kvepe7w0ej89btc7t; cf_chl_2=eff13178a8d7814; cf_clearance=Gti8UaeKBbXj2A7V0XFSGydeWbLj2VnqP83FnGx_wIU-1675675191-0-160" >> $GITHUB_ENV
|
||||||
|
echo "NHENTAI_UA=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36" >> $GITHUB_ENV
|
||||||
|
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: Set up Python 3.10
|
- name: Set up Python 3.10
|
||||||
uses: actions/setup-python@v3
|
uses: actions/setup-python@v3
|
@ -103,7 +103,7 @@ def favorites_parser(page=None):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def doujinshi_parser(id_):
|
def doujinshi_parser(id_, counter=0):
|
||||||
if not isinstance(id_, (int,)) and (isinstance(id_, (str,)) and not id_.isdigit()):
|
if not isinstance(id_, (int,)) and (isinstance(id_, (str,)) and not id_.isdigit()):
|
||||||
raise Exception(f'Doujinshi id({id_}) is not valid')
|
raise Exception(f'Doujinshi id({id_}) is not valid')
|
||||||
|
|
||||||
@ -112,7 +112,6 @@ def doujinshi_parser(id_):
|
|||||||
doujinshi = dict()
|
doujinshi = dict()
|
||||||
doujinshi['id'] = id_
|
doujinshi['id'] = id_
|
||||||
url = f'{constant.DETAIL_URL}/{id_}/'
|
url = f'{constant.DETAIL_URL}/{id_}/'
|
||||||
counter = 0
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = request('get', url)
|
response = request('get', url)
|
||||||
@ -126,11 +125,11 @@ def doujinshi_parser(id_):
|
|||||||
|
|
||||||
if counter == 10:
|
if counter == 10:
|
||||||
logger.critical(f'Failed to fetch doujinshi information of id {id_}')
|
logger.critical(f'Failed to fetch doujinshi information of id {id_}')
|
||||||
sys.exit(1)
|
return None
|
||||||
|
|
||||||
logger.debug(f'Slow down and retry ({id_}) ...')
|
logger.debug(f'Slow down and retry ({id_}) ...')
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
return doujinshi_parser(str(id_))
|
return doujinshi_parser(str(id_), counter)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(f'Error: {e}, ignored')
|
logger.warning(f'Error: {e}, ignored')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user