捕获异常并自动重试

This commit is contained in:
cwx committed 2022-12-09 21:18:23 +08:00
1 parent 2bde1350de
commit 96ce88c0eb
1 file changed
+6
+6
View File
@@ -85,6 +85,7 @@ class comicEntity:
''' '''
@classmethod @classmethod
def comicChapter(cls,chapter_url,scramble=None,sleep=None): def comicChapter(cls,chapter_url,scramble=None,sleep=None):
try:
cls.Onechapter(chapter_url,scramble) cls.Onechapter(chapter_url,scramble)
#进入下个阶段 #进入下个阶段
if comicInfo.nextExistsGetPath("down_"): if comicInfo.nextExistsGetPath("down_"):
@@ -99,6 +100,11 @@ class comicEntity:
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)