This commit is contained in:
caiwx86 2024-10-29 01:37:51 +08:00
parent c3de8413bf
commit 9ba828911e
2 changed files with 14 additions and 2 deletions

View File

@ -159,6 +159,7 @@ class ComicLoader(BaseLoader):
def set_schapter(self, value): self.set_properties('s_chapter', value=value)
def set_domain(self, value): self.set_properties('domain', value=value)
def get_domain(self): return self.get_output_value("domain")
def get_count(self): return self.get_output_value("count")
# 章节页码
def count(self):

View File

@ -7,6 +7,7 @@
# useful for handling different item types with a single interface
import os,scrapy,logging,shutil
from Comics import settings
from Comics.settings import IMAGES_STORE
from Comics._utils.items import ComicItem
from Comics._utils.loader import ComicLoader
from Comics._utils.utils import CBZUtils,fileUtils as fu
@ -90,7 +91,17 @@ class ImgDownloadPipeline(BaseImagesPipeline):
if os.path.isfile(path) and dirname.startswith(name):
fu.update_icon(path, cbz_icon)
def download_validate(self, item):
comic = ComicLoader(item=item)
# 获取需要解析下载的图像
images_item = comic.parse_images()
exist_images = []
for image_item in images_item:
image_path = os.path.join(IMAGES_STORE, image_item["image_path"])
if image_item["image_type"] == "Image" and os.path.exists(image_path): exist_images.append(image_path)
if len(comic.get_image_urls()) == len(exist_images) and len(exist_images) != 0 : return True
return False
def item_completed(self, results, item, info):
"""图片下载完成开始CBZ打包
不再做数据完整检验CBZUtils后续会自动检验
@ -101,7 +112,7 @@ class ImgDownloadPipeline(BaseImagesPipeline):
info (_type_): 信息
"""
# 存在未下载图像数据则重试
if not super().success_completed(item, results): return
if not self.download_validate(item): return self.get_media_requests(item, info)
# super().update_icon(item)
cbz_path = super().get_file_path(item, result_type="cbz")
chapter_dir = ComicPath(item=item).file_path(result_type=ComicPath().MAPPING_IMAGES_DIR)