fix
This commit is contained in:
parent
0320cf02fa
commit
dc917c2fc6
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,4 +1,5 @@
|
|||||||
COMICOUT/
|
COMICOUT/
|
||||||
.conf/
|
.conf/
|
||||||
**/__pycache__/**
|
**/__pycache__/**
|
||||||
|
.vscode/
|
||||||
logconf.log
|
logconf.log
|
||||||
@ -71,7 +71,7 @@ class baseComic:
|
|||||||
#不存在完成配置文件 则允许下载
|
#不存在完成配置文件 则允许下载
|
||||||
if not ciUtils.isProgressDone():
|
if not ciUtils.isProgressDone():
|
||||||
#if fu.exists(ComicPath.getNewCBZComicChapter("file")): ciUtils.setProgressDone()
|
#if fu.exists(ComicPath.getNewCBZComicChapter("file")): ciUtils.setProgressDone()
|
||||||
cls.comicChapters(href,scramble=True)
|
cls.comicChapters(href)
|
||||||
cls.count_chapter += 1
|
cls.count_chapter += 1
|
||||||
#一本漫画下载后等待
|
#一本漫画下载后等待
|
||||||
#清空文件夹
|
#清空文件夹
|
||||||
@ -85,10 +85,10 @@ class baseComic:
|
|||||||
读取某章节下所有图片
|
读取某章节下所有图片
|
||||||
'''
|
'''
|
||||||
@classmethod
|
@classmethod
|
||||||
def comicChapters(cls,chapter_url,scramble=None):
|
def comicChapters(cls,chapter_url):
|
||||||
is_next = False
|
is_next = False
|
||||||
#try:
|
#try:
|
||||||
cls.Onechapter(chapter_url,scramble)
|
cls.Onechapter(chapter_url)
|
||||||
#进入下个阶段
|
#进入下个阶段
|
||||||
#章节图片全部下载后,调用下载封面
|
#章节图片全部下载后,调用下载封面
|
||||||
comic_icon_path = ComicPath.getPathConfComicIcon()
|
comic_icon_path = ComicPath.getPathConfComicIcon()
|
||||||
@ -107,14 +107,14 @@ class baseComic:
|
|||||||
|
|
||||||
#根据章节地址下载全部图片,并将文件名scramble开头的图片进行解密
|
#根据章节地址下载全部图片,并将文件名scramble开头的图片进行解密
|
||||||
@classmethod
|
@classmethod
|
||||||
def Onechapter(cls,chapter_url,scramble=None):
|
def Onechapter(cls,chapter_url):
|
||||||
is_next = True
|
is_next = True
|
||||||
if not str(chapter_url).startswith("http"): chapter_url = ci.getBaseUrl() + chapter_url
|
if not str(chapter_url).startswith("http"): chapter_url = ci.getBaseUrl() + chapter_url
|
||||||
#下载图片
|
#下载图片
|
||||||
is_next = cls.comicChapterDownload(chapter_url)
|
is_next = cls.comicChapterDownload(chapter_url)
|
||||||
#下载完成后, 开始解密图片
|
#下载完成后, 开始解密图片
|
||||||
chapter_dir = ComicPath.getDirComicChapter()
|
chapter_dir = ComicPath.getDirComicChapter()
|
||||||
if scramble and os.path.exists(chapter_dir): #获取章节图片路径
|
if os.path.exists(chapter_dir): #获取章节图片路径
|
||||||
dirs = os.listdir(chapter_dir)
|
dirs = os.listdir(chapter_dir)
|
||||||
for img in dirs:
|
for img in dirs:
|
||||||
if img.startswith("scramble="):
|
if img.startswith("scramble="):
|
||||||
@ -135,16 +135,13 @@ class baseComic:
|
|||||||
#保存信息
|
#保存信息
|
||||||
ci.writeJson()
|
ci.writeJson()
|
||||||
#验证数据是已存在且是否完整
|
#验证数据是已存在且是否完整
|
||||||
is_next = CBZUtils.nextCBZ()
|
is_next = CBZUtils.isVerCBZComic()
|
||||||
is_update_old=CBZUtils.isUpdateOldCBZ()
|
|
||||||
#不存在ComicInfo.xml则生成
|
#不存在ComicInfo.xml则生成
|
||||||
if is_next and fu.notExists(ComicPath.getPathComicInfoXML()): ci.writeComicInfoXML()
|
if is_next and fu.notExists(ComicPath.getPathComicInfoXML()): ci.writeComicInfoXML()
|
||||||
if not is_next and not is_update_old:
|
|
||||||
ComicPath.TIME_SLEEP = 0.5
|
|
||||||
downloadUtils.queueDownClear()
|
|
||||||
else:
|
|
||||||
ComicPath.TIME_SLEEP = random.randint(8,15)
|
|
||||||
#图标
|
#图标
|
||||||
downloadUtils.putDownImageUrlDirFile(Comic.getIcon(),ComicPath.getDirConfComic(),ComicPath.COMIC_ICON_FILE_NAME)
|
downloadUtils.putDownImageUrlDirFile(Comic.getIcon(),ComicPath.getDirConfComic(),ComicPath.COMIC_ICON_FILE_NAME)
|
||||||
|
if not is_next:
|
||||||
|
CBZUtils.isUpdateOldCBZ()
|
||||||
downloadUtils.start_downloads(timeout=8)
|
downloadUtils.start_downloads(timeout=8)
|
||||||
|
if is_next and fu.notExists(ComicPath.getPathComicInfoXML()): ci.writeComicInfoXML()
|
||||||
return is_next
|
return is_next
|
||||||
@ -172,3 +172,18 @@ class ComicPath:
|
|||||||
@classmethod
|
@classmethod
|
||||||
def getPathComicInfoXML(cls,mkdir=True): return cls.setDirImg([Comic.getComicName(),Comic.getChapterName()
|
def getPathComicInfoXML(cls,mkdir=True): return cls.setDirImg([Comic.getComicName(),Comic.getChapterName()
|
||||||
,cls.COMIC_INFO_XML],mkdir=mkdir)
|
,cls.COMIC_INFO_XML],mkdir=mkdir)
|
||||||
|
#scramble图像路径
|
||||||
|
@classmethod
|
||||||
|
def getPathImageScrambleComicChapter(cls,count,block,mkdir=True,suffix="jpg"): return cls.setDirImg([Comic.getComicName(),Comic.getChapterName()
|
||||||
|
,"scramble="+block+"_"+count],mkdir=mkdir,suffix=suffix)
|
||||||
|
#
|
||||||
|
@classmethod
|
||||||
|
def getPathImageSaveScrambleComicChapter(cls,path,mkdir=True):
|
||||||
|
count = str(path).split("_")[-1]
|
||||||
|
return cls.setDirImg([Comic.getComicName(),Comic.getChapterName()
|
||||||
|
,count],mkdir=mkdir)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def getFileScrambleImageName(cls,count,block,suffix=".jpg"): return "scramble="+str(block)+"_"+str(count)+suffix
|
||||||
|
@classmethod
|
||||||
|
def getFileScrambleImageSave(cls,file): return str(file).split("_")[-1]
|
||||||
@ -7,6 +7,7 @@ from utils.FileUtils import imageUtils
|
|||||||
from utils.NetUtils import htmlUtils
|
from utils.NetUtils import htmlUtils
|
||||||
from utils.ComicUtils import ntfy
|
from utils.ComicUtils import ntfy
|
||||||
from utils.NetUtils import downloadUtils as downUtils
|
from utils.NetUtils import downloadUtils as downUtils
|
||||||
|
from utils.Logger import logger
|
||||||
|
|
||||||
class DomainDown:
|
class DomainDown:
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -36,11 +37,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)
|
||||||
image_src_suffix = "."+str(image_src).split(".")[-1]
|
image_src_suffix = "."+str(image_src).split(".")[-1]
|
||||||
|
image_file_name = count_image+image_src_suffix
|
||||||
if scramble:
|
if scramble:
|
||||||
de_str = str(image_src).split("/")[-1].replace(image_src_suffix,"==")
|
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
|
image_file_name = ComicPath.getFileScrambleImageName(count=count_image,block=blocks_num,suffix=image_src_suffix)
|
||||||
image_file_name = count_image+image_src_suffix
|
|
||||||
files_name.append(image_file_name)
|
files_name.append(image_file_name)
|
||||||
images_url.append(image_src)
|
images_url.append(image_src)
|
||||||
downUtils.putDownImageUrlDirFile(image_src,ComicPath.getDirComicChapter(),image_file_name)
|
downUtils.putDownImageUrlDirFile(image_src,ComicPath.getDirComicChapter(),image_file_name)
|
||||||
|
|||||||
@ -14,7 +14,7 @@ formatters:
|
|||||||
handlers:
|
handlers:
|
||||||
sh:
|
sh:
|
||||||
class: logging.StreamHandler
|
class: logging.StreamHandler
|
||||||
level: INFO
|
level: DEBUG
|
||||||
formatter: tostrout
|
formatter: tostrout
|
||||||
stream: ext://sys.stdout
|
stream: ext://sys.stdout
|
||||||
|
|
||||||
|
|||||||
@ -63,7 +63,7 @@ class CBZUtils:
|
|||||||
zf.write(path.joinpath(filename), arc_dir.joinpath(filename))
|
zf.write(path.joinpath(filename), arc_dir.joinpath(filename))
|
||||||
zf.close()
|
zf.close()
|
||||||
ntfy.sendMsg(f"打包完成:{target_file}")
|
ntfy.sendMsg(f"打包完成:{target_file}")
|
||||||
cls.verCBZComic(target_file)
|
cls.isVerCBZComic(target_file)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def packAutoComicChapterCBZ(cls):
|
def packAutoComicChapterCBZ(cls):
|
||||||
@ -129,8 +129,10 @@ class CBZUtils:
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
#CBZ检验是否完整
|
#CBZ检验是否完整
|
||||||
|
#正确True 错误False
|
||||||
@classmethod
|
@classmethod
|
||||||
def verCBZComic(cls,path=None,list_img=None,min_size=300000):
|
def isVerCBZComic(cls,path=None,list_img=None,min_size=300000):
|
||||||
|
is_ver = False
|
||||||
#数据检验
|
#数据检验
|
||||||
if path == None: path = cls.getCBZ_Path()
|
if path == None: path = cls.getCBZ_Path()
|
||||||
#文件不存在 则返回
|
#文件不存在 则返回
|
||||||
@ -150,7 +152,7 @@ class CBZUtils:
|
|||||||
ciUtils.setProgressFail()
|
ciUtils.setProgressFail()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
return False
|
return is_ver
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def isUpdateOldCBZ(cls,filesname=None,result=False):
|
def isUpdateOldCBZ(cls,filesname=None,result=False):
|
||||||
@ -176,10 +178,5 @@ class CBZUtils:
|
|||||||
fu.remove(unzip_path)
|
fu.remove(unzip_path)
|
||||||
return True
|
return True
|
||||||
ci.writeComicInfoXML(overlay=True)
|
ci.writeComicInfoXML(overlay=True)
|
||||||
result = False
|
is_update = False
|
||||||
return result
|
return is_update
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def nextCBZ(cls,list_img=None):
|
|
||||||
if list_img == None: list_img = Comic.getChapterImgs()
|
|
||||||
return not cls.verCBZComic(list_img=list_img)
|
|
||||||
@ -153,14 +153,9 @@ class imageUtils:
|
|||||||
#image.show()
|
#image.show()
|
||||||
file_str = str(imgpath).split("=")
|
file_str = str(imgpath).split("=")
|
||||||
#10_29.jpg
|
#10_29.jpg
|
||||||
base_dir = file_str[0].replace("scramble","")
|
base_fn = file_str[-1].split("_")
|
||||||
base_name = file_str[-1]
|
|
||||||
base_fn = base_name.split("_")
|
|
||||||
save_name = base_fn[1]
|
|
||||||
save_name_delesu = save_name.split(".")[0]
|
|
||||||
blocks = int(base_fn[0])
|
blocks = int(base_fn[0])
|
||||||
img_type = os.path.basename(imgpath).split('.')[-1]
|
save_path = ComicPath.getFileScrambleImageSave(imgpath)
|
||||||
save_path = os.path.join(os.path.dirname(imgpath),save_name_delesu+"."+img_type)
|
|
||||||
# print(type(aid),type(img_name))
|
# print(type(aid),type(img_name))
|
||||||
if blocks:
|
if blocks:
|
||||||
s = blocks # 随机值
|
s = blocks # 随机值
|
||||||
@ -324,7 +319,8 @@ class dbUtils:
|
|||||||
result = False
|
result = False
|
||||||
db = cls.init_db(db_name)
|
db = cls.init_db(db_name)
|
||||||
if db == None: return None
|
if db == None: return None
|
||||||
result = db.search(Query().name == name)
|
data = db.search(Query().name == name)
|
||||||
|
logger.info(f"result query= {data}")
|
||||||
if progress != None:
|
if progress != None:
|
||||||
try:
|
try:
|
||||||
if len(db.search((Query().name == name) & (Query().progress == progress))) != 0: result = True
|
if len(db.search((Query().name == name) & (Query().progress == progress))) != 0: result = True
|
||||||
|
|||||||
@ -188,6 +188,13 @@ class downloadUtils:
|
|||||||
result = cls.getDownUrlDirFileType()
|
result = cls.getDownUrlDirFileType()
|
||||||
if result == None: return None
|
if result == None: return None
|
||||||
(file_url,dir,file,file_type) = [result[0],result[1],result[2],result[3]]
|
(file_url,dir,file,file_type) = [result[0],result[1],result[2],result[3]]
|
||||||
|
logger.debug(f"file_url={file_url}, dir={dir} , file={file}, file_type={file_type}")
|
||||||
|
en_scrabmle_file = ComicPath.getFileScrambleImageSave(file)
|
||||||
|
save_path = os.path.join(dir,en_scrabmle_file)
|
||||||
|
logger.debug(f"save_path= {save_path}")
|
||||||
|
if os.path.exists(save_path):
|
||||||
|
logger.info(f"文件已存在,跳过中... {save_path}")
|
||||||
|
return True
|
||||||
if file_url == None:
|
if file_url == None:
|
||||||
logger.error("common_down file_url 为空")
|
logger.error("common_down file_url 为空")
|
||||||
raise NameError("common_down file_url为空")
|
raise NameError("common_down file_url为空")
|
||||||
@ -197,7 +204,6 @@ class downloadUtils:
|
|||||||
"http": proxy_type + "://" + proxy,
|
"http": proxy_type + "://" + proxy,
|
||||||
"https": proxy_type + "://" + proxy }
|
"https": proxy_type + "://" + proxy }
|
||||||
response = None
|
response = None
|
||||||
save_path = os.path.join(dir,file)
|
|
||||||
logger.debug(f"save_path {save_path}")
|
logger.debug(f"save_path {save_path}")
|
||||||
if not os.path.exists(dir): os.makedirs(dir)
|
if not os.path.exists(dir): os.makedirs(dir)
|
||||||
temp_path = save_path+".downloads"
|
temp_path = save_path+".downloads"
|
||||||
@ -244,7 +250,5 @@ class downloadUtils:
|
|||||||
with concurrent.futures.ThreadPoolExecutor(max_workers=concurrency) as executor:
|
with concurrent.futures.ThreadPoolExecutor(max_workers=concurrency) as executor:
|
||||||
future_list = list()
|
future_list = list()
|
||||||
while not cls.QUEUE_DOWN.empty():
|
while not cls.QUEUE_DOWN.empty():
|
||||||
logger.debug("QUEUE_DOWN 不为空 准备下载中...")
|
future_list.append(executor.submit(cls.common_download,timeout=timeout, proxy_type=proxy_type, proxy=proxy))
|
||||||
future_list.append(executor.submit(
|
|
||||||
cls.common_download,timeout, proxy_type, proxy))
|
|
||||||
concurrent.futures.wait(future_list, timeout)
|
concurrent.futures.wait(future_list, timeout)
|
||||||
Loading…
Reference in New Issue
Block a user