This commit is contained in:
cwx
2023-04-07 20:30:43 +08:00
parent e61beb42a8
commit b264f61a18
5 changed files with 49 additions and 39 deletions
+21 -34
View File
@@ -11,7 +11,6 @@ from common.ComicInfo import ComicInfo as ci
from common.Comic import Comic
from common.Comic import ListComic
from common.Constant import ComicPath
from utils.FileUtils import fileUtils
#中心框架
class baseComic:
@@ -70,9 +69,6 @@ class baseComic:
#if ciUtils.isProgressDone() and fu.notExists(ComicPath.getNewCBZComicChapter("file")):
# ciUtils.setProgressFail()
cbz_path = ComicPath.getPathCBZComicChapter()
#file_date = int(fileUtils.getModificationDate(cbz_path,"%Y%m%d%H",not_exists="2010010101"))
#if file_date > 2023040610 and file_date < 2023040710:
# os.remove(cbz_path)
if not os.path.exists(cbz_path):
print(f"CBZ不存在, {cbz_path}")
ciUtils.setProgressFail()
@@ -97,16 +93,7 @@ class baseComic:
is_next = False
#try:
cls.Onechapter(chapter_url)
#进入下个阶段
#章节图片全部下载后,调用下载封面
comic_icon_path = ComicPath.getPathConfComicIcon()
chapter_icon_path = ComicPath.getPathCBZComicChapterIcon()
if ciUtils.isProgressDown and os.path.exists(comic_icon_path) and not os.path.exists(chapter_icon_path):
shutil.copy(comic_icon_path,chapter_icon_path)
ntfy.sendMsg(f"复制成功:{comic_icon_path} -> {chapter_icon_path}")
ciUtils.iconDB()
ciUtils.setProgressCBZ()
#下个阶段
#下个阶段
if ciUtils.isProgressCBZ: is_next = CBZUtils.packAutoComicChapterCBZ()
#except Exception as e: is_next = ntfy.sendMsg(f"{ci.getComicName()} 下载出错了",error=e)
ntfy.sendMsg(f"预计总章节大小:{cls.count_chapter + 1} / "+ str(Comic.getLenChapters()),alert=True)
@@ -115,31 +102,16 @@ class baseComic:
#根据章节地址下载全部图片,并将文件名scramble开头的图片进行解密
@classmethod
def Onechapter(cls,chapter_url):
is_next = True
if not str(chapter_url).startswith("http"): chapter_url = ci.getBaseUrl() + chapter_url
def Onechapter(cls,url):
#下载图片
is_next = cls.comicChapterDownload(chapter_url)
#下载完成后, 开始解密图片
chapter_dir = ComicPath.getDirComicChapter()
if os.path.exists(chapter_dir): #获取章节图片路径
dirs = os.listdir(chapter_dir)
for img in dirs:
if img.startswith("scramble="):
imageUtils.encode_scramble_image(os.path.join(chapter_dir,img))
#进入下一阶段
ciUtils.setProgressDown()
return is_next
@classmethod
def comicChapterDownload(cls,url):
url = ComicPath.getUrl(url)
is_next = True
#获取本次工程的HOME目录
try:
domains.setdomain(url)
except:
htmlUtils.remove_HtmlCache(url)
cls.comicChapterDownload(url)
cls.Onechapter(url)
#保存信息
ci.writeJson()
#验证数据是已存在且是否完整
@@ -153,5 +125,20 @@ class baseComic:
ci.writeComicInfoXML()
ComicPath.TIME_SLEEP = random.randint(5,15)
downloadUtils.putDownImageUrlDirFile(Comic.getIcon(),ComicPath.getDirConfComic(),ComicPath.COMIC_ICON_FILE_NAME)
downloadUtils.start_downloads(timeout=15)
return is_next
downloadUtils.start_downloads(timeout=12.5,concurrency=10)
#下载完成后, 开始解密漫画章节下的加密图片
imageUtils.deScrambleImagesByDir(ComicPath.getDirComicChapter())
#进入下一阶段
#章节图片全部下载后,调用下载封面
cls.iconDownload()
ciUtils.setProgressCBZ()
@classmethod
def iconDownload(cls):
comic_icon_path = ComicPath.getPathConfComicIcon()
chapter_icon_path = ComicPath.getPathCBZComicChapterIcon()
if ciUtils.isProgressDown and os.path.exists(comic_icon_path) and not os.path.exists(chapter_icon_path):
shutil.copy(comic_icon_path,chapter_icon_path)
ntfy.sendMsg(f"复制成功:{comic_icon_path} -> {chapter_icon_path}")
ciUtils.iconDB()
+6
View File
@@ -86,7 +86,13 @@ class ComicPath:
COMIC_INFO_XML = "ComicInfo.xml"
TIME_SLEEP = 0.5
IS_UPDATE_COMIC = False
COMIC_SCRABMLE_COUNT = 0
@classmethod
def getUrl(cls,relative_url):
if not str(relative_url).startswith("http"): relative_url = pathStr.getBaseUrl(Comic.getHomePage())+relative_url
return relative_url
#顶级路径
@classmethod
def setJoinPathDir(cls,path,dir="",suffix=None,mkdir=False):