This commit is contained in:
cwx committed 2023-01-16 02:10:35 +08:00
1 parent 7542152145
commit a470f53317
2 files changed
+31 -2

No files matched your search

+29 -1
View File
@@ -1,9 +1,10 @@
import json import json
import os import os,shutil
from pathlib import Path from pathlib import Path
from zipfile import ZipFile from zipfile import ZipFile
from utils.comic.ComicInfo import comicInfo from utils.comic.ComicInfo import comicInfo
from utils.Ntfy import ntfy from utils.Ntfy import ntfy
from utils.FileUtils import fileUtils
class CBZUtils: class CBZUtils:
@@ -89,6 +90,33 @@ class CBZUtils:
zfile.close() zfile.close()
return data return data
@classmethod
def replaceZip(cls,filepath,unpack_dir=None):
if unpack_dir == None:
unpack_dir = str(filepath).split(".")[0]
fz = ZipFile(filepath, 'r')
for file in fz.namelist():
fz.extract(file, unpack_dir)
zip_imgs = os.listdir(unpack_dir)
is_file = None
for img in zip_imgs:
if img.endswith(".jpg"):
file_path = os.path.join(unpack_dir,img)
is_file = fileUtils.ver_file(file_path,"image")
if is_file != None and is_file == False:
shutil.rmtree(unpack_dir)
os.remove(file_path)
print(f"已删除{file_path}")
else:
print(f"数据完整:{file_path}")
# 删除删除main.ftl文件
#delete_filename = ''
#if os.path.exists(delete_filename):
# os.remove(delete_filename)
# time.sleep(60)
# shutil.copy(文件的路径,另一个目录);拷贝main.ftl到准备压缩的目录下
#cls.zip_compression()
class verUtils: class verUtils:
@classmethod @classmethod
def verCBZ(cls,data=None): def verCBZ(cls,data=None):
+2 -1
View File
@@ -37,8 +37,9 @@ class baseComic:
for chapter in chapters: for chapter in chapters:
comicInfo.setChapterIndex(chapter_index) comicInfo.setChapterIndex(chapter_index)
comicInfo.setChapterName(chapter) comicInfo.setChapterName(chapter)
comicInfo.getNewCBZComicChapter() cbz_path = comicInfo.getNewCBZComicChapter()
comicInfo.getNewIconComicChapter() comicInfo.getNewIconComicChapter()
CBZUtils.replaceZip(cbz_path)
chapter_index = chapter_index + 1 chapter_index = chapter_index + 1
return None return None