This commit is contained in:
caiwx86 2025-02-04 18:04:13 +08:00
parent 233e48da27
commit 86e0c63922

View File

@ -115,7 +115,13 @@ class MangaDownloader:
save_path = DirectoryNaming.manga_cover_dir(manga_info)
DirectoryNaming.ensure_dir(save_path.parent)
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:
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:
"""下载单个图片,增加重试机制、超时等待和文件缓存机制"""
if os.path.exists(FileNaming.getFileScrambleImageSave(save_path)): # 检查文件是否已存在
if FileNaming().file_update_by_date(save_path, remove=True):
logger.info(f"文件已存在,跳过下载: {save_path}")
return True
#file_path = FileNaming.getFileScrambleImageSave(save_path)
#if os.path.exists(file_path): # 检查文件是否已存在
# if not FileNaming().file_update_by_date(file_path, remove=True):
# logger.info(f"文件已存在,跳过下载: {file_path}")
# return True
# 从缓存中获取图片
cached_images = self.cache.get_image(url)
if cached_images: