捕获异常并自动重试

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 @classmethod
def comicChapter(cls,chapter_url,scramble=None,sleep=None): def comicChapter(cls,chapter_url,scramble=None,sleep=None):
cls.Onechapter(chapter_url,scramble) try:
#进入下个阶段 cls.Onechapter(chapter_url,scramble)
if comicInfo.nextExistsGetPath("down_"): #进入下个阶段
if comicInfo.nextExistsGetPath("down_"):
#章节图片全部下载后,调用下载封面 #章节图片全部下载后,调用下载封面
netUtils.downloadComicIcon() netUtils.downloadComicIcon()
#下个阶段 #下个阶段
if comicInfo.nextExistsGetPath("cbz_"): if comicInfo.nextExistsGetPath("cbz_"):
time.sleep(1) time.sleep(1)
#下载后自动打包 #下载后自动打包
CBZUtils.packAutoComicChapterCBZ() CBZUtils.packAutoComicChapterCBZ()
#完成删除原文件 #完成删除原文件
remove_path = comicInfo.getDirComicChapter() remove_path = comicInfo.getDirComicChapter()
shutil.rmtree(remove_path) shutil.rmtree(remove_path)
print(f"文件已删除: {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: if not sleep == None:
print(f"{sleep} 秒后开始下载下一个章节") print(f"{sleep} 秒后开始下载下一个章节")
time.sleep(sleep) time.sleep(sleep)