fix
This commit is contained in:
parent
3f2d9ee797
commit
1a6b9506e3
@ -956,6 +956,38 @@ class DBUtils:
|
||||
db.remove(Query().name == name)
|
||||
|
||||
class oldUtils:
|
||||
# 获取某个文件夹下的所有 ZIP 文件名,并移除 ".zip" 后缀
|
||||
def get_zip_files(self, folder_path):
|
||||
try:
|
||||
# 列出文件夹中的所有文件
|
||||
all_files = os.listdir(folder_path)
|
||||
# 筛选出扩展名为 .zip 的文件并移除 ".zip" 后缀
|
||||
zip_files = [os.path.splitext(file)[0] for file in all_files if file.lower().endswith('.zip')]
|
||||
return zip_files
|
||||
except Exception as e:
|
||||
print(f"获取 ZIP 文件失败: {e}")
|
||||
return []
|
||||
|
||||
def diff_cbz(self, cbz_dir, chapters):
|
||||
"""获取是否存在需要更新的CBZ
|
||||
|
||||
Args:
|
||||
cbz_dir (_type_): _description_
|
||||
chapters (_type_): _description_
|
||||
|
||||
Returns:
|
||||
_type_: _description_
|
||||
"""
|
||||
zip_files = self.get_zip_files(cbz_dir)
|
||||
print("ZIP 文件名(去除后缀)列表:")
|
||||
for zip_file in zip_files:
|
||||
print(zip_file)
|
||||
|
||||
# 找出 array1 中有但 array2 中没有的元素
|
||||
diff1 = list(set(zip_files) - set(chapters))
|
||||
print(f"diff= {diff1}")
|
||||
return diff1
|
||||
|
||||
def new_files(self, files, folder, suffix="CBZ", result_type="new"):
|
||||
result_files = self.old_files(files=files, folder=folder, suffix=suffix, result_type=result_type)
|
||||
new_files = []
|
||||
|
||||
@ -39,7 +39,8 @@ class RmComicSpider(scrapy.Spider):
|
||||
new_chapter = oldUtils().new_files(files=comic_item.get_chapters(), folder=cbz_dir)
|
||||
# 清理多余章节
|
||||
oldUtils().clean_old_files(files=comic_item.get_chapters(), folder=cbz_dir, move_folder=move_folder)
|
||||
for chapter, link in zip(comic_item.get_chapters(), comic_item.get_chapter_href()):
|
||||
if len(oldUtils().diff_cbz(cbz_dir=cbz_dir, chapters=new_chapter)) > 0:
|
||||
for chapter, link in zip(comic_item.get_chapters(), comic_item.get_chapter_href()):
|
||||
if ComicPath.chinese_convert(ComicPath.fix_file_name(chapter)) in new_chapter:
|
||||
# 打包导出item数据
|
||||
item = comic_item.load_item(chapter=chapter)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user