fix 仅检查模式下,预览操作不会删除任何文件。

This commit is contained in:
thsrite
2024-06-27 16:10:27 +08:00
parent 528be1adbb
commit 9e8f80a058
3 changed files with 9 additions and 6 deletions

View File

@@ -46,4 +46,4 @@ MoviePilot三方插件市场https://github.com/thsrite/MoviePilot-Plugins/
- CloudDrive2助手 v1.2
- 软连接重定向 v1.0
- 云盘同步删除 v1.3
- 媒体库重复媒体检测 v1.7
- 媒体库重复媒体检测 v1.8

View File

@@ -588,11 +588,12 @@
"name": "媒体库重复媒体检测",
"description": "媒体库重复媒体检查,可选保留规则保留其一。",
"labels": "云盘,媒体库",
"version": "1.7",
"version": "1.8",
"icon": "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/libraryduplicate.png",
"author": "thsrite",
"level": 2,
"history": {
"v1.8": "仅检查模式下,预览操作不会删除任何文件。",
"v1.7": "修复特殊场景下删除问题",
"v1.6": "同步删除thumb图片等刮削文件",
"v1.5": "删除重复文件时再刷新媒体库逻辑",

View File

@@ -30,7 +30,7 @@ class LibraryDuplicateCheck(_PluginBase):
# 插件图标
plugin_icon = "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/libraryduplicate.png"
# 插件版本
plugin_version = "1.7"
plugin_version = "1.8"
# 插件作者
plugin_author = "thsrite"
# 作者主页
@@ -248,9 +248,11 @@ class LibraryDuplicateCheck(_PluginBase):
logger.info(f" {path} 文件已被删除")
# Decide which file to keep based on criteria (e.g., file size or creation date)
logger.info(f"文件保留规则:{str(retain_type)}")
keep_file = self.__choose_file_to_keep(paths, retain_type)
logger.info(f"文件保留规则:{str(retain_type)} Keeping: {keep_file}")
logger.info(f"本地保留文件: {keep_file}")
keep_cloud_file = os.readlink(str(keep_file))
logger.info(f"云盘保留文件: {keep_cloud_file}")
# Delete the other duplicate files (if needed)
for path in paths:
@@ -280,8 +282,8 @@ class LibraryDuplicateCheck(_PluginBase):
cloud_file_path = Path(duplicate_file)
# 删除文件、nfo、jpg等同名文件
pattern = cloud_file_path.stem.replace('[', '?').replace(']', '?')
logger.info(f"开始筛选 {cloud_file_path.parent} 下同名文件 {pattern}")
files = cloud_file_path.parent.glob(f"{pattern}.*")
files = list(cloud_file_path.parent.glob(f"{pattern}.*"))
logger.info(f"筛选 {cloud_file_path.parent} 下同名文件 {pattern}.* {len(files)}")
media_files = []
for file in files:
if Path(file).suffix.lower() in [ext.strip() for ext in