make download_one_file() more general

This commit is contained in:
lededev
2021-10-23 19:28:20 +08:00
parent 03954c3a35
commit db1ad1d582

View File

@@ -223,7 +223,7 @@ def _download_one_file(url: str, save_path: Path):
filebytes = get_html(url, return_type='content')
if isinstance(filebytes, bytes) and len(filebytes):
if len(filebytes) == save_path.open('wb').write(filebytes):
return f'[+]Image Downloaded! {save_path}'
return str(save_path)
return None
def extrafanart_download_threadpool(url_list, save_dir, number, source_movie):
@@ -243,7 +243,7 @@ def extrafanart_download_threadpool(url_list, save_dir, number, source_movie):
with ThreadPoolExecutor(os.cpu_count()) as pool:
result = pool.map(download_one_file, mp_args)
for s in result:
print(s) if s else None
print('[+]Image Downloaded!', s) if s else None
if not all(result): # 非致命错误电影不移入失败文件夹将来可以用模式3补齐
print('[-]Failed download some extrafanart images for number [{number}], you may retry run mode 3 later.')
if conf.debug():