fix
This commit is contained in:
parent
233e48da27
commit
86e0c63922
@ -115,7 +115,13 @@ class MangaDownloader:
|
|||||||
save_path = DirectoryNaming.manga_cover_dir(manga_info)
|
save_path = DirectoryNaming.manga_cover_dir(manga_info)
|
||||||
DirectoryNaming.ensure_dir(save_path.parent)
|
DirectoryNaming.ensure_dir(save_path.parent)
|
||||||
if os.path.exists(save_path):
|
if os.path.exists(save_path):
|
||||||
print("f".format(save_path))
|
if FileNaming().file_update_by_date(save_path, day=7):
|
||||||
|
"""需要更新刚删除原文件"""
|
||||||
|
os.remove(save_path)
|
||||||
|
else:
|
||||||
|
"""不更新刚返回"""
|
||||||
|
logger.info(f"{save_path} 已是更新")
|
||||||
|
return
|
||||||
async with aiohttp.ClientSession(headers=DEFAULT_HEADERS, timeout=aiohttp.ClientTimeout(total=TIMEOUT, connect=TIMEOUT)) as session:
|
async with aiohttp.ClientSession(headers=DEFAULT_HEADERS, timeout=aiohttp.ClientTimeout(total=TIMEOUT, connect=TIMEOUT)) as session:
|
||||||
await self.download_image(session,str(cover_item.url), save_path)
|
await self.download_image(session,str(cover_item.url), save_path)
|
||||||
|
|
||||||
@ -198,10 +204,11 @@ class MangaDownloader:
|
|||||||
|
|
||||||
async def download_image(self, session: aiohttp.ClientSession, url: str, save_path: Path, retries: int = RETRIES, timeout: int = TIMEOUT, use_proxy: bool = RETRY_PROXY) -> bool:
|
async def download_image(self, session: aiohttp.ClientSession, url: str, save_path: Path, retries: int = RETRIES, timeout: int = TIMEOUT, use_proxy: bool = RETRY_PROXY) -> bool:
|
||||||
"""下载单个图片,增加重试机制、超时等待和文件缓存机制"""
|
"""下载单个图片,增加重试机制、超时等待和文件缓存机制"""
|
||||||
if os.path.exists(FileNaming.getFileScrambleImageSave(save_path)): # 检查文件是否已存在
|
#file_path = FileNaming.getFileScrambleImageSave(save_path)
|
||||||
if FileNaming().file_update_by_date(save_path, remove=True):
|
#if os.path.exists(file_path): # 检查文件是否已存在
|
||||||
logger.info(f"文件已存在,跳过下载: {save_path}")
|
# if not FileNaming().file_update_by_date(file_path, remove=True):
|
||||||
return True
|
# logger.info(f"文件已存在,跳过下载: {file_path}")
|
||||||
|
# return True
|
||||||
# 从缓存中获取图片
|
# 从缓存中获取图片
|
||||||
cached_images = self.cache.get_image(url)
|
cached_images = self.cache.get_image(url)
|
||||||
if cached_images:
|
if cached_images:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user