fix
This commit is contained in:
parent
293179ba90
commit
e36431adf6
@ -1,9 +1,6 @@
|
|||||||
import json,os
|
import json,os
|
||||||
from typing import Any
|
|
||||||
from xml.dom.minidom import Document
|
from xml.dom.minidom import Document
|
||||||
from common.Constant import pathStr
|
|
||||||
from utils.FileUtils import dbUtils as db
|
from utils.FileUtils import dbUtils as db
|
||||||
from utils.FileUtils import fileUtils
|
|
||||||
from common.Comic import Comic
|
from common.Comic import Comic
|
||||||
from common.Constant import ComicPath
|
from common.Constant import ComicPath
|
||||||
|
|
||||||
@ -22,7 +19,6 @@ class ComicInfoEntity:
|
|||||||
Comic.dict_cbs,Comic.dict_genre,Comic.dict_tags,Comic.dict_page_count,
|
Comic.dict_cbs,Comic.dict_genre,Comic.dict_tags,Comic.dict_page_count,
|
||||||
Comic.dict_language,Comic.dict_agerating,Comic.dict_pages,Comic.dict_chapter_imgs]
|
Comic.dict_language,Comic.dict_agerating,Comic.dict_pages,Comic.dict_chapter_imgs]
|
||||||
class ComicInfo:
|
class ComicInfo:
|
||||||
COMIC_ICON_NAME = "000"
|
|
||||||
IS_NEW_ICON = False
|
IS_NEW_ICON = False
|
||||||
document = Document()
|
document = Document()
|
||||||
path_comic_info = None
|
path_comic_info = None
|
||||||
@ -61,7 +57,7 @@ class ComicInfo:
|
|||||||
if cls.IS_NEW_ICON:
|
if cls.IS_NEW_ICON:
|
||||||
#添加封面
|
#添加封面
|
||||||
icon_node = cls.document.createElement("Page")
|
icon_node = cls.document.createElement("Page")
|
||||||
icon_node.setAttribute("Image",cls.COMIC_ICON_NAME)
|
icon_node.setAttribute("Image",ComicPath.COMIC_ICON_NAME)
|
||||||
icon_node.setAttribute("Type","FrontCover")
|
icon_node.setAttribute("Type","FrontCover")
|
||||||
root_node.appendChild(icon_node)
|
root_node.appendChild(icon_node)
|
||||||
for page in values:
|
for page in values:
|
||||||
|
|||||||
@ -75,6 +75,7 @@ class pathStr:
|
|||||||
return week
|
return week
|
||||||
|
|
||||||
class ComicPath:
|
class ComicPath:
|
||||||
|
COMIC_ICON_NAME = "000"
|
||||||
DEFAULT_PATH = "default"
|
DEFAULT_PATH = "default"
|
||||||
PROGRESS_PATH = "progress"
|
PROGRESS_PATH = "progress"
|
||||||
ICONS_PATH = "icons"
|
ICONS_PATH = "icons"
|
||||||
@ -110,6 +111,9 @@ class ComicPath:
|
|||||||
#章节配置json文件路径
|
#章节配置json文件路径
|
||||||
@classmethod
|
@classmethod
|
||||||
def getPathConfComicChapterJson(cls,mkdir=True): return cls.setDirConf([Comic.getOriginComicName(),Comic.getOriginChapterName()],suffix="json",mkdir=mkdir)
|
def getPathConfComicChapterJson(cls,mkdir=True): return cls.setDirConf([Comic.getOriginComicName(),Comic.getOriginChapterName()],suffix="json",mkdir=mkdir)
|
||||||
|
#漫画Icon路径
|
||||||
|
@classmethod
|
||||||
|
def getPathConfComicIcon(cls,mkdir=True,suffix="jpg"): return cls.setDirConf([Comic.getOriginComicName(),cls.COMIC_ICON_NAME],suffix=suffix,mkdir=mkdir)
|
||||||
#Icons json文件路径
|
#Icons json文件路径
|
||||||
@classmethod
|
@classmethod
|
||||||
def getDirConfDefault(cls,path=None,suffix=None,mkdir=True): return cls.setDirConf([cls.DEFAULT_PATH,path],suffix=suffix,mkdir=mkdir)
|
def getDirConfDefault(cls,path=None,suffix=None,mkdir=True): return cls.setDirConf([cls.DEFAULT_PATH,path],suffix=suffix,mkdir=mkdir)
|
||||||
@ -121,7 +125,10 @@ class ComicPath:
|
|||||||
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,suffix=None): return cls.setDirCBZ([Comic.getComicName(),Comic.getChapterName()],suffix=suffix)
|
||||||
|
#漫画章节CBZ同根下封面
|
||||||
|
@classmethod
|
||||||
|
def getPathCBZComicChapterIcon(cls,suffix="jpg"): return cls.setDirCBZ([Comic.getComicName(),Comic.getChapterName()],suffix=suffix)
|
||||||
#旧版本漫画章节CBZ路径
|
#旧版本漫画章节CBZ路径
|
||||||
@classmethod
|
@classmethod
|
||||||
def getPathOldCBZComicChapter(cls): return cls.setDirOld([Comic.getOriginComicName(),Comic.getOriginChapterName()],suffix="CBZ")
|
def getPathOldCBZComicChapter(cls): return cls.setDirOld([Comic.getOriginComicName(),Comic.getOriginChapterName()],suffix="CBZ")
|
||||||
|
|||||||
@ -121,7 +121,7 @@ class CBZUtils:
|
|||||||
with ZipFile(path, "r") as zip_file:
|
with ZipFile(path, "r") as zip_file:
|
||||||
result = zip_file.namelist()
|
result = zip_file.namelist()
|
||||||
if filter:
|
if filter:
|
||||||
filter_icon = ci.COMIC_ICON_NAME+".jpg"
|
filter_icon = ComicPath.COMIC_ICON_NAME+".jpg"
|
||||||
filter_info_xml = ComicPath.COMIC_INFO_XML
|
filter_info_xml = ComicPath.COMIC_INFO_XML
|
||||||
if filter_icon in result: result.remove(filter_icon)
|
if filter_icon in result: result.remove(filter_icon)
|
||||||
if filter_info_xml in result: result.remove(filter_info_xml)
|
if filter_info_xml in result: result.remove(filter_info_xml)
|
||||||
|
|||||||
@ -248,16 +248,13 @@ class downloadUtils:
|
|||||||
if icon_url == None:
|
if icon_url == None:
|
||||||
print("icon 不存在,已跳过")
|
print("icon 不存在,已跳过")
|
||||||
return None
|
return None
|
||||||
save_name = ci.COMIC_ICON_NAME
|
icon_suffix = str(icon_url).split(".")[-1]
|
||||||
icon_suffix = "."+str(icon_url).split(".")[-1]
|
|
||||||
icon_suffix = icon_suffix.split("?")[0]
|
|
||||||
#判断漫画名路径是否已存在comicname/cover.jpg, 存在跳过
|
#判断漫画名路径是否已存在comicname/cover.jpg, 存在跳过
|
||||||
path_comic_icon = os.path.join(ComicPath.getDirConfComic(),save_name+icon_suffix)
|
path_comic_icon = ComicPath.getPathConfComicIcon()
|
||||||
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_suffix])
|
cls.download_images([icon_url],ComicPath.getDirConfComic(),files_name=[ComicPath.COMIC_ICON_NAME+"."+icon_suffix])
|
||||||
save_path = os.path.join(ComicPath.getDirCBZComic(),Comic.getChapterName()+icon_suffix)
|
save_path = ComicPath.getPathCBZComicChapterIcon(icon_suffix)
|
||||||
if is_new:
|
if is_new:
|
||||||
#历史版本ICON
|
#历史版本ICON
|
||||||
if os.path.exists(save_path):
|
if os.path.exists(save_path):
|
||||||
@ -265,11 +262,12 @@ 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_suffix))
|
shutil.copy(path_comic_icon,os.path.join(base_dir,ComicPath.COMIC_ICON_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)
|
if fu.notExists(save_path):
|
||||||
print(f"{path_comic_icon} 已复制至: {save_path}")
|
shutil.copy(path_comic_icon,save_path)
|
||||||
|
print(f"{path_comic_icon} 已复制至: {save_path}")
|
||||||
#保存icon信息
|
#保存icon信息
|
||||||
ciUtils.iconDB()
|
ciUtils.iconDB()
|
||||||
ciUtils.setProgressCBZ()
|
ciUtils.setProgressCBZ()
|
||||||
Loading…
Reference in New Issue
Block a user