This commit is contained in:
cwx committed 2023-06-22 22:03:35 +08:00
1 parent e6eadefe34
commit 7672b7c84b
6 files changed
+86 -43

No files matched your search

+11 -12
View File
@@ -275,30 +275,27 @@ class CBZUtils:
y = 0
for filename in filenames:
y = y + 1
logging.info(f"打包中:" + str(y) + "/" + str(len(filenames)), os.path.join(source_dir, filename))
print("打包中:" + str(y) + "/" + str(len(filenames)), os.path.join(source_dir, filename))
zf.write(path.joinpath(filename), arc_dir.joinpath(filename))
zf.close()
logging.info(f"打包完成:{target_file}")
@classmethod
def packComicChapterCBZ(cls, comic, chapter, comic_info_images, remove=True):
images_chapter_path = os.path.join(IMAGES_STORE, comic, chapter)
cbz_chapter_path = os.path.join(CBZ_EXPORT_PATH, comic, chapter) + ".CBZ"
if os.path.exists(images_chapter_path):
dirs = os.listdir(images_chapter_path)
def packComicChapterCBZ(cls, src_dir, dts_path, comic_info_images, remove=True):
if os.path.exists(src_dir):
dirs = os.listdir(src_dir)
for file in dirs:
if file.startswith(ComicPath.PREFIX_SCRAMBLE):
try:
imageUtils.deScrambleImagesByPath(os.path.join(images_chapter_path,file))
imageUtils.deScrambleImagesByPath(os.path.join(src_dir,file))
except Exception as e:
print(f"删除 {file} 发生错误 {e},已跳过")
return False
cls.zip_compression(images_chapter_path, cbz_chapter_path)
cls.zip_compression(src_dir, dts_path)
time.sleep(0.1)
if remove: shutil.rmtree(images_chapter_path)
if remove: shutil.rmtree(src_dir)
# validation
cls.cbz_validate(cbz_chapter_path, comic_info_images)
return True
return cls.cbz_validate(dts_path, comic_info_images)
@classmethod
def replaceZip(cls, filepath, unpack_dir=None):
@@ -356,6 +353,8 @@ class CBZUtils:
def cbz_validate(cls, zip_path, comic_info_images):
if len(cls.zip_info(zip_path)) == len(comic_info_images):
logging.info(f"validating successfully === {zip_path}")
return True
else:
os.remove(zip_path)
logging.error(f"validating fail === {zip_path}")
logging.error(f"validating fail === {zip_path}")
return False