捕获异常并自动重试

This commit is contained in:
cwx 2022-12-09 21:18:23 +08:00
parent 2bde1350de
commit 96ce88c0eb

View File

@ -85,20 +85,26 @@ class comicEntity:
'''
@classmethod
def comicChapter(cls,chapter_url,scramble=None,sleep=None):
cls.Onechapter(chapter_url,scramble)
#进入下个阶段
if comicInfo.nextExistsGetPath("down_"):
try:
cls.Onechapter(chapter_url,scramble)
#进入下个阶段
if comicInfo.nextExistsGetPath("down_"):
#章节图片全部下载后,调用下载封面
netUtils.downloadComicIcon()
#下个阶段
if comicInfo.nextExistsGetPath("cbz_"):
time.sleep(1)
netUtils.downloadComicIcon()
#下个阶段
if comicInfo.nextExistsGetPath("cbz_"):
time.sleep(1)
#下载后自动打包
CBZUtils.packAutoComicChapterCBZ()
CBZUtils.packAutoComicChapterCBZ()
#完成删除原文件
remove_path = comicInfo.getDirComicChapter()
shutil.rmtree(remove_path)
print(f"文件已删除: {remove_path}")
remove_path = comicInfo.getDirComicChapter()
shutil.rmtree(remove_path)
print(f"文件已删除: {remove_path}")
except:
dirComicChapter = comicInfo.getDirComicChapter
if not dirComicChapter == None and os.path.exists(dirComicChapter):
shutil.rmtree(dirComicChapter)
cls.comicChapter(chapter_url,scramble,sleep)
if not sleep == None:
print(f"{sleep} 秒后开始下载下一个章节")
time.sleep(sleep)