fix
This commit is contained in:
parent
537b4d8827
commit
d05897e11f
@ -6,7 +6,15 @@ from utils.comic.ComicInfo import comicInfo
|
||||
from utils.Ntfy import ntfy
|
||||
|
||||
class CBZUtils:
|
||||
|
||||
@classmethod
|
||||
def getCBZ_Dir(cls):
|
||||
return comicInfo.getNewCBZComicChapter()
|
||||
|
||||
@classmethod
|
||||
def getCBZ_Path(cls):
|
||||
return cls.getCBZ_Dir()+".CBZ"
|
||||
|
||||
@classmethod
|
||||
def readDirsOrFiles(cls,dir,type):
|
||||
data = []
|
||||
@ -47,7 +55,6 @@ class CBZUtils:
|
||||
@classmethod
|
||||
def packAutoComicChapterCBZ(cls):
|
||||
chapter_path = comicInfo.getDirComicChapter()
|
||||
packCBZ_path = comicInfo.getDirCBZComicChapter()
|
||||
if os.path.exists(chapter_path):
|
||||
dirs = os.listdir(chapter_path)
|
||||
for file in dirs:
|
||||
@ -57,14 +64,14 @@ class CBZUtils:
|
||||
except:
|
||||
print(f"删除 {file} 发生错误,已跳过")
|
||||
try:
|
||||
size_zip = cls.zip_compression(chapter_path,packCBZ_path+".CBZ")
|
||||
size_zip = cls.zip_compression(chapter_path, cls.getCBZ_Path())
|
||||
size_imgs = len(comicInfo.getChapterImgs())
|
||||
if size_zip -1 == size_imgs:
|
||||
ntfy.sendMsg(f"打包校验成功: {packCBZ_path}")
|
||||
ntfy.sendMsg(f"打包校验成功: {cls.getCBZ_Path()}")
|
||||
comicInfo.nextCBZToDoneChapter()
|
||||
return True
|
||||
else:
|
||||
ntfy.sendMsg(f"打包检验不完整:{packCBZ_path}")
|
||||
ntfy.sendMsg(f"打包检验不完整:{cls.getCBZ_Path()}")
|
||||
return False
|
||||
|
||||
except:
|
||||
@ -73,9 +80,8 @@ class CBZUtils:
|
||||
|
||||
@classmethod
|
||||
def zip_info(cls,zip_path=None):
|
||||
pack_cbz_path = comicInfo.getDirCBZComicChapter()
|
||||
if zip_path == None:
|
||||
zip_path = pack_cbz_path+".CBZ"
|
||||
zip_path = cls.getCBZ_Path()
|
||||
data = None
|
||||
if os.path.exists(zip_path):
|
||||
with ZipFile(zip_path, "r") as zfile:
|
||||
@ -120,7 +126,7 @@ class verUtils:
|
||||
@classmethod
|
||||
def verNextCBZ(cls,list_img):
|
||||
#验证数据是已存在且是否完整
|
||||
cbz_path = comicInfo.getDirCBZComicChapter()+".CBZ"
|
||||
cbz_path = CBZUtils.getCBZ_Path()
|
||||
is_next = False
|
||||
if os.path.exists(cbz_path):
|
||||
try:
|
||||
|
||||
@ -39,8 +39,9 @@ class comicInfo():
|
||||
str_web = None
|
||||
str_list_img = None
|
||||
str_files_img = None
|
||||
str_chapter_index= None
|
||||
str_value1 = None
|
||||
|
||||
|
||||
chapter_node = None
|
||||
comicName_node = None
|
||||
dep_node = None
|
||||
@ -216,6 +217,14 @@ class comicInfo():
|
||||
value = ",".join(to_list)
|
||||
return value
|
||||
|
||||
@classmethod
|
||||
def setChapterIndex(cls,value):
|
||||
cls.str_chapter_index = value
|
||||
|
||||
@classmethod
|
||||
def getChapterIndex(cls):
|
||||
return cls.str_chapter_index
|
||||
|
||||
'''
|
||||
获取网站主页
|
||||
'''
|
||||
@ -263,17 +272,34 @@ class comicInfo():
|
||||
if not cls.str_comicName == None:
|
||||
return os.path.join(pathStr.base_cbz, cls.str_comicName)
|
||||
else:
|
||||
print("comicName不存在,退出中")
|
||||
print("comicName不存在,退出中 getDirCBZComic")
|
||||
exit()
|
||||
|
||||
@classmethod
|
||||
def getDirCBZComicChapter(cls):
|
||||
if not cls.str_comicName == None and not cls.str_chapter == None:
|
||||
if cls.str_comicName != None and cls.str_chapter != None:
|
||||
return os.path.join(pathStr.base_cbz,cls.str_comicName,cls.str_chapter)
|
||||
else:
|
||||
print("comicName不存在,退出中")
|
||||
print("comicName不存在,退出中 getDirCBZComicChapter")
|
||||
exit()
|
||||
|
||||
|
||||
@classmethod
|
||||
def getSortDirCBZComicChapter(cls):
|
||||
if cls.str_comicName != None and cls.str_chapter != None and cls.str_chapter_index != None:
|
||||
return os.path.join(pathStr.base_cbz,cls.str_comicName,str(cls.str_chapter_index)+" "+cls.str_chapter)
|
||||
else:
|
||||
print("comicName不存在,退出中 getSortDirCBZComicChapter")
|
||||
return None
|
||||
|
||||
@classmethod
|
||||
def getNewCBZComicChapter(cls):
|
||||
c_path = cls.getDirCBZComicChapter()
|
||||
s_path = cls.getSortDirCBZComicChapter()
|
||||
if os.path.exists(c_path) and s_path != None:
|
||||
shutil.move(c_path, s_path)
|
||||
print("文件已移动至:", s_path)
|
||||
return s_path
|
||||
|
||||
@classmethod
|
||||
def getDirComic(cls):
|
||||
if cls.str_comicName != None:
|
||||
|
||||
@ -106,6 +106,9 @@ def download_comic_icon():
|
||||
if not os.path.exists(pathCBZComic):
|
||||
os.makedirs(pathCBZComic)
|
||||
save_path = os.path.join(pathCBZComic,comicInfo.getChapter()+icon_su)
|
||||
index = comicInfo.getChapterIndex()
|
||||
if index != None:
|
||||
save_path = os.path.join(pathCBZComic,str(index)+" "+comicInfo.getChapter()+icon_su)
|
||||
shutil.copy(pathComicIcon, save_path)
|
||||
print(f"{pathComicIcon} 已复制至: {save_path}")
|
||||
comicInfo.nextDownloadToCBZChapter()
|
||||
|
||||
@ -29,6 +29,13 @@ class baseComic:
|
||||
return comic_href
|
||||
else:
|
||||
ntfy.sendMsg(f"{book_name} 已是最新")
|
||||
chapters = htmlUtils.xpathData('//div[contains(@class,"bookid_chapterBox")]//div[contains(@class,"bookid_chapter")]/a/text()',url=comic_href,update=False)
|
||||
chapter_index = 1
|
||||
for chapter in chapters:
|
||||
comicInfo.setChapterIndex(chapter_index)
|
||||
comicInfo.setChapterName(chapter)
|
||||
comicInfo.getNewCBZComicChapter()
|
||||
chapter_index = chapter_index + 1
|
||||
return None
|
||||
|
||||
#print(books)
|
||||
@ -55,6 +62,7 @@ class baseComic:
|
||||
cls.count_chapter = 0
|
||||
for href in chapter_href:
|
||||
chapter = chapters[cls.count_chapter]
|
||||
comicInfo.setChapterIndex(cls.count_chapter+1)
|
||||
comicInfo.setChapterName(chapter)
|
||||
if not comicInfo.nextExistsGetPath("done_"):
|
||||
cls.comicChapter(href,scramble=True,sleep=random.randint(5,15))
|
||||
@ -98,6 +106,7 @@ class baseComic:
|
||||
# ntfy.sendMsg(f"{comicInfo.getComicName()} 下载出错了")
|
||||
# is_next = False
|
||||
ntfy.sendMsg(f"预计总章节大小:{cls.count_chapter + 1} / "+ str(comicInfo.getLenChapters()))
|
||||
comicInfo.setChapterIndex(cls.count_chapter + 1)
|
||||
if sleep != None and is_next == True:
|
||||
ntfy.sendMsg(f"{sleep} 秒后开始下载下一个章节")
|
||||
time.sleep(sleep)
|
||||
@ -139,7 +148,8 @@ class baseComic:
|
||||
#保存图像
|
||||
comicInfo.nextSaveInfoChapter(chapter_name, list_img)
|
||||
#验证数据是已存在且是否完整
|
||||
cbz_path = comicInfo.getDirCBZComicChapter()+".CBZ"
|
||||
#cbz_path = comicInfo.getDirCBZComicChapter()+".CBZ"
|
||||
cbz_path = comicInfo.getNewCBZComicChapter()+".CBZ"
|
||||
is_next = True
|
||||
if os.path.exists(cbz_path):
|
||||
try:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user