This commit is contained in:
caiwx86 2023-04-05 23:10:46 +08:00
parent 1fa0ee45df
commit c9febe8d3e

View File

@ -186,6 +186,7 @@ class downloadUtils:
time.sleep(0.7)
cls.download_image(image_url,dst_dir,file_name)
print(f'重试:第{repair_count}{image_url}')
cls.down_queue.put([file_name,image_url,dst_dir])
repair_count += 1
with open(temp_path, 'wb') as f:
f.write(response.content)
@ -200,20 +201,13 @@ class downloadUtils:
@classmethod
def download_image(cls,timeout=20, proxy_type=None, proxy=None,type="image"):
repeat = 0
while not cls.down_queue.empty() and repeat <= 15:
repeat += 1
repeat = 1
while not cls.down_queue.empty() and repeat <= 10:
data = cls.down_queue.get(False)
(file_name,image_url,dst_dir) = [data[0],data[1],data[2]]
if repeat > 1:
print(f"{repeat}次下载数据中... file_name={file_name}")
try:
cls.common_download(file_name,image_url,dst_dir,timeout=timeout,
proxy=proxy,proxy_type=proxy_type,type=type)
except:
print(f"下载重试中 {file_name}={image_url}")
time.sleep(1)
cls.down_queue.put([file_name,image_url,dst_dir])
repeat += 1
@classmethod
@ -252,7 +246,7 @@ class downloadUtils:
return None
icon_suffix = str(icon_url).split(".")[-1]
#判断漫画名路径是否已存在comicname/cover.jpg, 存在跳过
path_comic_icon = ComicPath.getPathConfComicIcon()
path_comic_icon = ComicPath.getPathConfComicIcon(suffix=icon_suffix)
if not ciUtils.equIcon() and fu.exists(path_comic_icon): os.remove(path_comic_icon)
if fu.notExists(path_comic_icon):
cls.download_images([icon_url],ComicPath.getDirConfComic(),files_name=[ComicPath.COMIC_ICON_NAME+"."+icon_suffix],timeout=30)