This commit is contained in:
caiwx86 2023-01-20 03:53:57 +08:00
parent b695764e00
commit fc78bcada6

View File

@ -37,7 +37,7 @@ def download_image(image_url, dst_dir, file_name, timeout=20, proxy_type=None, p
response = None
file_path = os.path.join(dst_dir, file_name)
if os.path.exists(file_path):
print("文件已存在,已跳过=",file_path)
print("download_image 文件已存在,已跳过=",file_path)
return None
temp_path = os.path.join(dst_dir, file_name+".downloads")
repair_count = 1
@ -87,8 +87,12 @@ def download_images(image_urls, dst_dir, file_prefix="img", concurrency=50, time
if not os.path.exists(dst_dir):
os.makedirs(dst_dir)
for image_url in image_urls:
file_name = filesName[count]
future_list.append(executor.submit(
file_name = filesName[count]
file_path = os.path.join(dst_dir, file_name)
if os.path.exists(file_path):
print("文件已存在,已跳过=",file_path)
else:
future_list.append(executor.submit(
download_image, image_url, dst_dir, file_name, timeout, proxy_type, proxy))
count += 1
concurrent.futures.wait(future_list, timeout)