mirror of
https://github.com/RicterZ/nhentai.git
synced 2025-04-12 06:23:30 +02:00
fix #349
This commit is contained in:
parent
13b584a820
commit
803957ba88
@ -38,8 +38,12 @@ FAV_URL = f'{BASE_URL}/favorites/'
|
||||
|
||||
IMAGE_URL = f'{urlparse(BASE_URL).scheme}://i.{urlparse(BASE_URL).hostname}/galleries'
|
||||
IMAGE_URL_MIRRORS = [
|
||||
f'{urlparse(BASE_URL).scheme}://i1.{urlparse(BASE_URL).hostname}',
|
||||
f'{urlparse(BASE_URL).scheme}://i2.{urlparse(BASE_URL).hostname}',
|
||||
f'{urlparse(BASE_URL).scheme}://i3.{urlparse(BASE_URL).hostname}',
|
||||
f'{urlparse(BASE_URL).scheme}://i4.{urlparse(BASE_URL).hostname}',
|
||||
f'{urlparse(BASE_URL).scheme}://i5.{urlparse(BASE_URL).hostname}',
|
||||
f'{urlparse(BASE_URL).scheme}://i6.{urlparse(BASE_URL).hostname}',
|
||||
f'{urlparse(BASE_URL).scheme}://i7.{urlparse(BASE_URL).hostname}',
|
||||
]
|
||||
|
||||
|
@ -47,7 +47,10 @@ class Downloader(Singleton):
|
||||
for completed_task in asyncio.as_completed(tasks):
|
||||
try:
|
||||
result = await completed_task
|
||||
logger.info(f'{result[1]} download completed')
|
||||
if result[1]:
|
||||
logger.info(f'{result[1]} download completed')
|
||||
else:
|
||||
logger.warning(f'{result[1]} download failed, return value {result[0]}')
|
||||
except Exception as e:
|
||||
logger.error(f'An error occurred: {e}')
|
||||
|
||||
@ -85,11 +88,11 @@ class Downloader(Singleton):
|
||||
|
||||
if not await self.save(filename, response):
|
||||
logger.error(f'Can not download image {url}')
|
||||
return 1, None
|
||||
return 1, url
|
||||
|
||||
except (httpx.HTTPStatusError, httpx.TimeoutException, httpx.ConnectError) as e:
|
||||
if retried < 3:
|
||||
logger.info(f'Download {filename} failed, retrying({retried + 1}) times...')
|
||||
logger.warning(f'Download {filename} failed, retrying({retried + 1}) times...')
|
||||
return await self.download(
|
||||
url=url,
|
||||
folder=folder,
|
||||
@ -98,7 +101,8 @@ class Downloader(Singleton):
|
||||
proxy=proxy,
|
||||
)
|
||||
else:
|
||||
return 0, None
|
||||
logger.warning(f'Download {filename} failed with 3 times retried, skipped')
|
||||
return 0, url
|
||||
|
||||
except NHentaiImageNotExistException as e:
|
||||
os.remove(save_file_path)
|
||||
@ -110,10 +114,10 @@ class Downloader(Singleton):
|
||||
logger.error(f"Exception type: {type(e)}")
|
||||
traceback.print_stack()
|
||||
logger.critical(str(e))
|
||||
return 0, None
|
||||
return 0, url
|
||||
|
||||
except KeyboardInterrupt:
|
||||
return -3, None
|
||||
return -3, url
|
||||
|
||||
return 1, url
|
||||
|
||||
|
@ -157,8 +157,12 @@ def doujinshi_parser(id_, counter=0):
|
||||
|
||||
ext = []
|
||||
for i in html.find_all('div', attrs={'class': 'thumb-container'}):
|
||||
_, ext_name = os.path.basename(i.img.attrs['data-src']).rsplit('.', 1)
|
||||
ext.append(ext_name)
|
||||
base_name = os.path.basename(i.img.attrs['data-src'])
|
||||
ext_name = base_name.split('.')
|
||||
if len(ext_name) == 2:
|
||||
ext.append(ext_name[-1])
|
||||
elif len(ext_name) == 3:
|
||||
ext.append(ext_name[1])
|
||||
|
||||
if not img_id:
|
||||
logger.critical(f'Tried yo get image id failed of id: {id_}')
|
||||
|
Loading…
x
Reference in New Issue
Block a user