diff --git a/utils/NetUtils.py b/utils/NetUtils.py index f7204ce..967d461 100644 --- a/utils/NetUtils.py +++ b/utils/NetUtils.py @@ -92,3 +92,9 @@ class netUtils: shutil.copy(pathComicIcon, save_path) print(f"{pathComicIcon} 已复制至: {save_path}") comicInfo.nextDownloadToCBZChapter() + + @classmethod + def sendMsg(cls, msg): + print(f"#ntfy: {msg}") + requests.post("https://ntfy.caiwenxiu.cn/PyComic", + data=msg.encode(encoding='utf-8')) \ No newline at end of file diff --git a/utils/entity/RouMan.py b/utils/entity/RouMan.py index 362f01d..4987c8e 100644 --- a/utils/entity/RouMan.py +++ b/utils/entity/RouMan.py @@ -29,13 +29,13 @@ class comicEntity: book_name = book.get("name") updatedAt = book.get("updatedAt") comicHref = baseUrl+"/books/"+book_id - random_int = random.uniform(5,20) + random_int = random.randint(5,20) comicInfo.setComicName(book_name) - dirConfComic = comicInfo.getDirConfComic() - if not os.path.exists(dirConfComic): - print(f"{random_int}秒后开始下载 漫画:{book_name}") - time.sleep(random_int) - cls.oneComic(comicHref, random.uniform(0,3)) + #dirConfComic = comicInfo.getDirConfComic() + #if not os.path.exists(dirConfComic): + netUtils.sendMsg(f"{random_int}秒后开始下载 漫画:{book_name}") + time.sleep(random_int) + cls.oneComic(comicHref, random.uniform(0,3)) print(books) #for comicHref in comicsHref: @@ -76,7 +76,7 @@ class comicEntity: chapter = chapters[count_chapter] comicInfo.setChapterName(chapter) if not comicInfo.nextExistsGetPath("done_"): - comicEntity.comicChapter(href,scramble=True,sleep=random.uniform(15,25)) + comicEntity.comicChapter(href,scramble=True,sleep=random.randint(15,25)) count_chapter += 1 #一本漫画下载后等待 #清空文件夹 @@ -106,14 +106,14 @@ class comicEntity: #完成删除原文件 remove_path = comicInfo.getDirComicChapter() shutil.rmtree(remove_path) - print(f"文件已删除: {remove_path}") + netUtils.sendMsg(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} 秒后开始下载下一个章节") + netUtils.sendMsg(f"{sleep} 秒后开始下载下一个章节") time.sleep(sleep) @classmethod @@ -149,6 +149,7 @@ class comicEntity: description = x.get("description") images = x.get("images") chapterAPIPath = x.get("chapterAPIPath") + netUtils.sendMsg(f"{bookName} {chapterName} 下载中") comicInfo.setComicName(bookName) comicInfo.setChapterName(chapterName) comicInfo.setDep(description) @@ -165,7 +166,7 @@ class comicEntity: chapterName = data.get("name") images = data.get("images") if images == None: - print(f"未获取到章节图像 comic_name={bookName} chapter={chapterName}") + netUtils.sendMsg(f"未获取到章节图像 comic_name={bookName} chapter={chapterName}") totalChapter = x.get("totalChapter") tags = x.get("tags") x = tags