This commit is contained in:
cwx
2023-04-05 00:12:18 +08:00
parent 80a544672a
commit 0c126aab22
10 changed files with 246 additions and 233 deletions
+6 -3
View File
@@ -122,7 +122,7 @@ class CBZUtils:
result = zip_file.namelist()
if filter:
filter_icon = ci.COMIC_ICON_NAME+".jpg"
filter_info_xml = ci.COMIC_INFO_XML
filter_info_xml = ComicPath.COMIC_INFO_XML
if filter_icon in result: result.remove(filter_icon)
if filter_info_xml in result: result.remove(filter_info_xml)
except Exception as e:
@@ -138,15 +138,18 @@ class CBZUtils:
if fu.notExists(path): return False
if list_img == None: list_img = Comic.getChapterImgs()
if ciUtils.isProgressDone():
print(f"该文件已校验成功,跳过中... {path}")
return True
if fu.exists(path) and len(cls.zip_info(path)) == len(list_img):
print(f"文件校验成功:{path}")
ciUtils.setProgress(ciUtils.PROGRESS_DONE)
ciUtils.setProgressDone()
return True
else:
try:
if len(cls.zip_info(path)) < len(list_img) or os.path.getsize(path) < min_size:
fu.remove(path)
ciUtils.setProgress(ciUtils.PROGRESS_NONE)
ciUtils.setProgressFail()
except Exception as e:
print(e)
return False
+6 -13
View File
@@ -2,7 +2,8 @@ import base64,hashlib,os,shutil
import math,time,json
from PIL import Image
from tinydb import TinyDB, Query
from common.Constant import pathStr
from common.Constant import ComicPath
from common.Comic import Comic
class imageUtils:
@@ -302,20 +303,11 @@ class fileUtils:
class dbUtils:
@classmethod
def base_path(cls,path):
base_dir = pathStr.base_db()
if not os.path.exists(base_dir):
os.makedirs(base_dir)
return os.path.join(base_dir,path)
def init_db(cls,db_name):
return TinyDB(ComicPath.getDirConfDefault(db_name,prefix="json"))
@classmethod
def init_db(cls,db_name=None):
if db_name != None: db_name = cls.base_path(db_name)+".json"
else: db_name = "Comics.json"
return TinyDB(cls.base_path(db_name))
@classmethod
def setComic(cls,name,progress,db_name=None):
def set(cls,name,progress,db_name):
db = cls.init_db(db_name)
comic = Query()
if len(db.search(comic.name == name)) == 0: db.insert({"name":name,"progress":progress})
@@ -324,6 +316,7 @@ class dbUtils:
@classmethod
def query(cls,name,progress=None,db_name=None):
db = cls.init_db(db_name)
if db == None: return None
result = db.search(Query().name == name)
if progress != None:
try:
+1 -4
View File
@@ -257,8 +257,6 @@ class downloadUtils:
os.remove(path_comic_icon)
if fu.notExists(path_comic_icon):
cls.download_images([icon_url],ComicPath.getDirConfComic(),files_name=[save_name+icon_prefix])
#if not os.path.exists(path_cbz_comic):
# os.makedirs(path_cbz_comic)
save_path = os.path.join(ComicPath.getDirCBZComic(),Comic.getChapterName()+icon_prefix)
if is_new:
#历史版本ICON
@@ -274,5 +272,4 @@ class downloadUtils:
print(f"{path_comic_icon} 已复制至: {save_path}")
#保存icon信息
ciUtils.iconDB()
ciUtils.nextDownloadToCBZChapter()
ciUtils.setProgress(ciUtils.PROGRESS_CBZ)
ciUtils.setProgressCBZ()