diff --git a/utils/HtmlUtils.py b/utils/HtmlUtils.py index 42103e2..ae584fa 100644 --- a/utils/HtmlUtils.py +++ b/utils/HtmlUtils.py @@ -36,7 +36,17 @@ class htmlUtils: os.makedirs(dir_name) with open(file_path,"w",encoding="utf-8") as fs: fs.write(str(data)) - + + @classmethod + def remove_HtmlCache(cls,url): + file_path = cls.getPathSaveHtml(url,type="new") + if os.path.exists(file_path): + try: + os.remove(file_path) + print("已删除") + except: + print() + @classmethod def getHTML(cls, curl,type=None): retries = Retry(total=3, diff --git a/utils/entity/RouMan.py b/utils/entity/RouMan.py index 24be582..c28cc4b 100644 --- a/utils/entity/RouMan.py +++ b/utils/entity/RouMan.py @@ -175,10 +175,15 @@ class comicEntity: if chapterAPIPath != None: base_url = comicInfo.getBaseUrl(chapter_url) chapterAPIUrl = base_url+chapterAPIPath - data = json.loads(htmlUtils.getJSON(chapterAPIUrl)) - data = data.get("chapter") - chapterName = data.get("name") - images = data.get("images") + try: + data = htmlUtils.getJSON(chapterAPIUrl) + data = data.get("chapter") + chapterName = data.get("name") + images = data.get("images") + except: + htmlUtils.remove_HtmlCache(chapterAPIUrl) + ntfy.sendMsg("存在错误,请退出后尝试") + exit() if images == None: ntfy.sendMsg(f"未获取到章节图像 comic_name={bookName} chapter={chapterName}")