fix
This commit is contained in:
parent
b9a55a8344
commit
293179ba90
@ -82,7 +82,7 @@ class ComicPath:
|
|||||||
|
|
||||||
#顶级路径
|
#顶级路径
|
||||||
@classmethod
|
@classmethod
|
||||||
def setJoinPathDir(cls,path,dir="",prefix=None,mkdir=False):
|
def setJoinPathDir(cls,path,dir="",suffix=None,mkdir=False):
|
||||||
result = dir
|
result = dir
|
||||||
if isinstance(path,dict) or isinstance(path,list):
|
if isinstance(path,dict) or isinstance(path,list):
|
||||||
for x in path:
|
for x in path:
|
||||||
@ -93,33 +93,38 @@ class ComicPath:
|
|||||||
if not os.path.exists(base_dir):
|
if not os.path.exists(base_dir):
|
||||||
os.makedirs(base_dir)
|
os.makedirs(base_dir)
|
||||||
print(f"新路径 {result} mkdir={mkdir}")
|
print(f"新路径 {result} mkdir={mkdir}")
|
||||||
if prefix != None: result += "."+prefix
|
if suffix != None: result += "."+suffix
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setDirConf(cls,path,prefix=None,mkdir=False): return cls.setJoinPathDir(path,pathStr.base_conf_path(),prefix=prefix,mkdir=mkdir)
|
def setDirConf(cls,path,suffix=None,mkdir=False): return cls.setJoinPathDir(path,pathStr.base_conf_path(),suffix=suffix,mkdir=mkdir)
|
||||||
@classmethod
|
@classmethod
|
||||||
def setDirCBZ(cls,path,prefix=None,mkdir=False): return cls.setJoinPathDir(path,pathStr.base_cbz(),prefix=prefix,mkdir=mkdir)
|
def setDirCBZ(cls,path,suffix=None,mkdir=False): return cls.setJoinPathDir(path,pathStr.base_cbz(),suffix=suffix,mkdir=mkdir)
|
||||||
@classmethod
|
@classmethod
|
||||||
def setDirImg(cls,path,prefix=None,mkdir=False): return cls.setJoinPathDir(path,pathStr.base_comic_img(),prefix=prefix,mkdir=mkdir)
|
def setDirImg(cls,path,suffix=None,mkdir=False): return cls.setJoinPathDir(path,pathStr.base_comic_img(),suffix=suffix,mkdir=mkdir)
|
||||||
|
@classmethod
|
||||||
|
def setDirOld(cls,path,suffix=None,mkdir=False): return cls.setJoinPathDir(path,pathStr.old_cbz_path,suffix=suffix,mkdir=mkdir)
|
||||||
#漫画配置文件路径
|
#漫画配置文件路径
|
||||||
@classmethod
|
@classmethod
|
||||||
def getDirConfComic(cls): return cls.setDirConf(Comic.getOriginComicName())
|
def getDirConfComic(cls): return cls.setDirConf(Comic.getOriginComicName())
|
||||||
#章节配置json文件路径
|
#章节配置json文件路径
|
||||||
@classmethod
|
@classmethod
|
||||||
def getPathConfComicChapterJson(cls,mkdir=True): return cls.setDirConf([Comic.getOriginComicName(),Comic.getOriginChapterName()],prefix="json",mkdir=mkdir)
|
def getPathConfComicChapterJson(cls,mkdir=True): return cls.setDirConf([Comic.getOriginComicName(),Comic.getOriginChapterName()],suffix="json",mkdir=mkdir)
|
||||||
#Icons json文件路径
|
#Icons json文件路径
|
||||||
@classmethod
|
@classmethod
|
||||||
def getDirConfDefault(cls,path=None,prefix=None,mkdir=True): return cls.setDirConf([cls.DEFAULT_PATH,path],prefix=prefix,mkdir=mkdir)
|
def getDirConfDefault(cls,path=None,suffix=None,mkdir=True): return cls.setDirConf([cls.DEFAULT_PATH,path],suffix=suffix,mkdir=mkdir)
|
||||||
#漫画进度文件
|
#漫画进度文件
|
||||||
@classmethod
|
@classmethod
|
||||||
def getPathProgressJson(cls,mkdir=True): return cls.setDirConf([cls.PROGRESS_PATH,Comic.getOriginComicName()],prefix="json",mkdir=mkdir)
|
def getPathProgressJson(cls,mkdir=True): return cls.setDirConf([cls.PROGRESS_PATH,Comic.getOriginComicName()],suffix="json",mkdir=mkdir)
|
||||||
#漫画CBZ路径
|
#漫画CBZ路径
|
||||||
@classmethod
|
@classmethod
|
||||||
def getDirCBZComic(cls): return cls.setDirCBZ(Comic.getComicName())
|
def getDirCBZComic(cls): return cls.setDirCBZ(Comic.getComicName())
|
||||||
#漫画章节CBZ路径
|
#漫画章节CBZ路径
|
||||||
@classmethod
|
@classmethod
|
||||||
def getDirCBZComicChapter(cls): return cls.setDirCBZ([Comic.getComicName(),Comic.getChapterName()])
|
def getDirCBZComicChapter(cls): return cls.setDirCBZ([Comic.getComicName(),Comic.getChapterName()])
|
||||||
|
#旧版本漫画章节CBZ路径
|
||||||
|
@classmethod
|
||||||
|
def getPathOldCBZComicChapter(cls): return cls.setDirOld([Comic.getOriginComicName(),Comic.getOriginChapterName()],suffix="CBZ")
|
||||||
#排序
|
#排序
|
||||||
@classmethod
|
@classmethod
|
||||||
def getSortDirCBZComicChapter(cls): return cls.setDirCBZ([Comic.getComicName()],str(Comic.getNumber())+" "+Comic.getChapterName())
|
def getSortDirCBZComicChapter(cls): return cls.setDirCBZ([Comic.getComicName()],str(Comic.getNumber())+" "+Comic.getChapterName())
|
||||||
|
|||||||
@ -34,11 +34,11 @@ class DomainDown:
|
|||||||
(image_src,scramble) = [image.get("src"),image.get("scramble")]
|
(image_src,scramble) = [image.get("src"),image.get("scramble")]
|
||||||
count_image = "{:0>3d}".format(count)
|
count_image = "{:0>3d}".format(count)
|
||||||
list_img.append(image_src)
|
list_img.append(image_src)
|
||||||
image_src_prefix = "."+str(image_src).split(".")[-1]
|
image_src_suffix = "."+str(image_src).split(".")[-1]
|
||||||
if scramble:
|
if scramble:
|
||||||
de_str = str(image_src).split("/")[-1].replace(image_src_prefix,"==")
|
de_str = str(image_src).split("/")[-1].replace(image_src_suffix,"==")
|
||||||
blocks_num = imageUtils.encodeImage(de_str)
|
blocks_num = imageUtils.encodeImage(de_str)
|
||||||
count_image = "scramble="+str(blocks_num)+"_"+count_image
|
count_image = "scramble="+str(blocks_num)+"_"+count_image
|
||||||
list_file_name.append(count_image+image_src_prefix)
|
list_file_name.append(count_image+image_src_suffix)
|
||||||
count+=1
|
count+=1
|
||||||
ciUtils.comicChapterDownload(list_img,list_file_name)
|
ciUtils.comicChapterDownload(list_img,list_file_name)
|
||||||
@ -156,8 +156,8 @@ class CBZUtils:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def updateOldCBZ(cls,filesname,result=False):
|
def updateOldCBZ(cls,filesname,result=False):
|
||||||
old_zipfile_path = ComicPath.setJoinPathDir([OldUtils.getOldComicName(),OldUtils.getOldChapter()],
|
old_zipfile_path = ComicPath.getPathOldCBZComicChapter()
|
||||||
pathStr.old_cbz_path,prefix="CBZ")
|
|
||||||
#判断是否存在已下载CBZ文件
|
#判断是否存在已下载CBZ文件
|
||||||
if fu.exists(old_zipfile_path) and fu.notExists(CBZUtils.getCBZ_Path()):
|
if fu.exists(old_zipfile_path) and fu.notExists(CBZUtils.getCBZ_Path()):
|
||||||
print(f"存在CBZ文件{old_zipfile_path},解压中...")
|
print(f"存在CBZ文件{old_zipfile_path},解压中...")
|
||||||
|
|||||||
@ -55,7 +55,7 @@ class imageUtils:
|
|||||||
block_height = int(height / blocks)
|
block_height = int(height / blocks)
|
||||||
block_width = int(width / blocks)
|
block_width = int(width / blocks)
|
||||||
print("blockHeight=",block_height)
|
print("blockHeight=",block_height)
|
||||||
prefix = str(file_path).split(".")[-1]
|
suffix = str(file_path).split(".")[-1]
|
||||||
split_path = os.path.join(base_dir,save_name_delesu+"split")
|
split_path = os.path.join(base_dir,save_name_delesu+"split")
|
||||||
if image_su == "downloads":
|
if image_su == "downloads":
|
||||||
return None
|
return None
|
||||||
@ -242,7 +242,7 @@ class fileUtils:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def dirFilesName(cls,path,type="file",prefix=None):
|
def dirFilesName(cls,path,type="file",suffix=None):
|
||||||
result = []
|
result = []
|
||||||
if cls.exists(path):
|
if cls.exists(path):
|
||||||
for file_or_dir in os.listdir(path):
|
for file_or_dir in os.listdir(path):
|
||||||
@ -251,11 +251,11 @@ class fileUtils:
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def equImages(cls,dir,files,prefix=".jpg"):
|
def equImages(cls,dir,files,suffix=".jpg"):
|
||||||
len_count = 0
|
len_count = 0
|
||||||
file_names = cls.dirFilesName(dir,"file")
|
file_names = cls.dirFilesName(dir,"file")
|
||||||
for file in file_names:
|
for file in file_names:
|
||||||
if str(file).endswith(prefix): len_count += 1
|
if str(file).endswith(suffix): len_count += 1
|
||||||
return len_count == len(files)
|
return len_count == len(files)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -304,7 +304,7 @@ class fileUtils:
|
|||||||
class dbUtils:
|
class dbUtils:
|
||||||
@classmethod
|
@classmethod
|
||||||
def init_db(cls,db_name):
|
def init_db(cls,db_name):
|
||||||
return TinyDB(ComicPath.getDirConfDefault(db_name,prefix="json"))
|
return TinyDB(ComicPath.getDirConfDefault(db_name,suffix="json"))
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def set(cls,name,progress,db_name):
|
def set(cls,name,progress,db_name):
|
||||||
|
|||||||
@ -223,7 +223,7 @@ class downloadUtils:
|
|||||||
:param proxy_type:
|
:param proxy_type:
|
||||||
:param image_urls: list of image urls
|
:param image_urls: list of image urls
|
||||||
:param dst_dir: output the downloaded images to dst_dir
|
:param dst_dir: output the downloaded images to dst_dir
|
||||||
:param file_prefix: if set to "img", files will be in format "img_xxx.jpg"
|
:param file_suffix: if set to "img", files will be in format "img_xxx.jpg"
|
||||||
:param concurrency: number of requests process simultaneously
|
:param concurrency: number of requests process simultaneously
|
||||||
:return: none
|
:return: none
|
||||||
"""
|
"""
|
||||||
@ -249,15 +249,15 @@ class downloadUtils:
|
|||||||
print("icon 不存在,已跳过")
|
print("icon 不存在,已跳过")
|
||||||
return None
|
return None
|
||||||
save_name = ci.COMIC_ICON_NAME
|
save_name = ci.COMIC_ICON_NAME
|
||||||
icon_prefix = "."+str(icon_url).split(".")[-1]
|
icon_suffix = "."+str(icon_url).split(".")[-1]
|
||||||
icon_prefix = icon_prefix.split("?")[0]
|
icon_suffix = icon_suffix.split("?")[0]
|
||||||
#判断漫画名路径是否已存在comicname/cover.jpg, 存在跳过
|
#判断漫画名路径是否已存在comicname/cover.jpg, 存在跳过
|
||||||
path_comic_icon = os.path.join(ComicPath.getDirConfComic(),save_name+icon_prefix)
|
path_comic_icon = os.path.join(ComicPath.getDirConfComic(),save_name+icon_suffix)
|
||||||
if not ciUtils.equIcon() and fu.exists(path_comic_icon):
|
if not ciUtils.equIcon() and fu.exists(path_comic_icon):
|
||||||
os.remove(path_comic_icon)
|
os.remove(path_comic_icon)
|
||||||
if fu.notExists(path_comic_icon):
|
if fu.notExists(path_comic_icon):
|
||||||
cls.download_images([icon_url],ComicPath.getDirConfComic(),files_name=[save_name+icon_prefix])
|
cls.download_images([icon_url],ComicPath.getDirConfComic(),files_name=[save_name+icon_suffix])
|
||||||
save_path = os.path.join(ComicPath.getDirCBZComic(),Comic.getChapterName()+icon_prefix)
|
save_path = os.path.join(ComicPath.getDirCBZComic(),Comic.getChapterName()+icon_suffix)
|
||||||
if is_new:
|
if is_new:
|
||||||
#历史版本ICON
|
#历史版本ICON
|
||||||
if os.path.exists(save_path):
|
if os.path.exists(save_path):
|
||||||
@ -265,7 +265,7 @@ class downloadUtils:
|
|||||||
if os.path.exists(path_comic_icon):
|
if os.path.exists(path_comic_icon):
|
||||||
base_dir = ComicPath.getDirComicChapter()
|
base_dir = ComicPath.getDirComicChapter()
|
||||||
if not os.path.exists(base_dir): os.makedirs(base_dir)
|
if not os.path.exists(base_dir): os.makedirs(base_dir)
|
||||||
shutil.copy(path_comic_icon,os.path.join(base_dir,save_name+icon_prefix))
|
shutil.copy(path_comic_icon,os.path.join(base_dir,save_name+icon_suffix))
|
||||||
else:
|
else:
|
||||||
if fu.notExists(ComicPath.getDirCBZComic()): os.makedirs(ComicPath.getDirCBZComic())
|
if fu.notExists(ComicPath.getDirCBZComic()): os.makedirs(ComicPath.getDirCBZComic())
|
||||||
shutil.copy(path_comic_icon,save_path)
|
shutil.copy(path_comic_icon,save_path)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user