This commit is contained in:
caiwx86 2023-04-01 15:07:37 +08:00
parent 2b47018f27
commit 936aaf1a59
2 changed files with 22 additions and 4 deletions

View File

@ -47,7 +47,7 @@ class imageUtils:
try:
img = Image.open(file_path)
except:
print(f"error Image")
print(f"error Image: {file_path}")
width = img.width
height = img.height
#blocks = cls.encodeImage(enStr)
@ -241,6 +241,23 @@ class fileUtils:
print(e)
return False
@classmethod
def dirFilesName(cls,path,type="file",prefix=None):
result = []
if cls.exists(path):
for file_or_dir in os.listdir(path):
if type == "file" and os.path.isfile(os.path.join(path,file_or_dir)): result.append(file_or_dir)
if type == "dir" and os.path.isdir(os.path.join(path,file_or_dir)): result.append(file_or_dir)
return result
@classmethod
def equImages(cls,dir,files,prefix=".jpg"):
len_count = 0
file_names = cls.dirFilesName(dir,"file")
for file in file_names:
if str(file).endswith(prefix): len_count += 1
return len_count == len(files)
@classmethod
def remove(cls,path):
if not os.path.exists(path):

View File

@ -120,13 +120,14 @@ class baseComic:
#检验CBZ文件
CBZUtils.verCBZComic(cbz_file)
CBZUtils.updateOldCBZ(files_name)
is_next = CBZUtils.nextCBZ()
#不存在ComicInfo.xml则生成
if is_next and fu.notExists(ci.getPathComicInfoXML()): ci.writeComicInfoXML(chapter_name)
repeat = 1
while CBZUtils.nextCBZ() and repeat <= 10:
while is_next and repeat <= 10:
ntfy.sendMsg(f"{book_name} {chapter_name} 下载中")
download_images(list_img,ci.getDirComicChapter(), files_name=files_name,concurrency=None,timeout=8)
equ_next = len(",".join(os.listdir(ci.getDirComicChapter())).split(".jpg")) == len(list_img)
if not equ_next: ntfy.sendMsg(msg=f"下载数据(不完整,{int(repeat*2)}秒钟后尝试第{repeat}",sleep=int(repeat*2))
is_next = fu.equImages(ci.getDirComicChapter(),list_img)
if not is_next: ntfy.sendMsg(msg=f"下载数据(不完整,{int(repeat*2)}秒钟后尝试第{repeat}",sleep=int(repeat*2))
repeat += 1
return is_next