This commit is contained in:
caiwx86 2022-12-22 13:40:16 +08:00
parent 02455f96d8
commit e0ebedb95a
2 changed files with 20 additions and 5 deletions

View File

@ -36,7 +36,17 @@ class htmlUtils:
os.makedirs(dir_name) os.makedirs(dir_name)
with open(file_path,"w",encoding="utf-8") as fs: with open(file_path,"w",encoding="utf-8") as fs:
fs.write(str(data)) 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 @classmethod
def getHTML(cls, curl,type=None): def getHTML(cls, curl,type=None):
retries = Retry(total=3, retries = Retry(total=3,

View File

@ -175,10 +175,15 @@ class comicEntity:
if chapterAPIPath != None: if chapterAPIPath != None:
base_url = comicInfo.getBaseUrl(chapter_url) base_url = comicInfo.getBaseUrl(chapter_url)
chapterAPIUrl = base_url+chapterAPIPath chapterAPIUrl = base_url+chapterAPIPath
data = json.loads(htmlUtils.getJSON(chapterAPIUrl)) try:
data = data.get("chapter") data = htmlUtils.getJSON(chapterAPIUrl)
chapterName = data.get("name") data = data.get("chapter")
images = data.get("images") chapterName = data.get("name")
images = data.get("images")
except:
htmlUtils.remove_HtmlCache(chapterAPIUrl)
ntfy.sendMsg("存在错误,请退出后尝试")
exit()
if images == None: if images == None:
ntfy.sendMsg(f"未获取到章节图像 comic_name={bookName} chapter={chapterName}") ntfy.sendMsg(f"未获取到章节图像 comic_name={bookName} chapter={chapterName}")