This commit is contained in:
cwx 2022-12-13 00:09:05 +08:00
parent 50b0fc8119
commit 3d00520c14
2 changed files with 17 additions and 10 deletions

View File

@ -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'))

View File

@ -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