From 1930b0cb8b1e1c3ff141e572aba0d66076d04dd9 Mon Sep 17 00:00:00 2001 From: thsrite Date: Thu, 12 Dec 2024 11:32:07 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E4=BF=AE=E5=A4=8D=E5=85=A8=E9=87=8F?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E5=A4=84=E7=90=86=E9=9D=9E=E5=AA=92=E4=BD=93?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.v2.json | 2 +- plugins.v2/cloudstrmcompanion/__init__.py | 49 +++++++++++++++-------- 2 files changed, 33 insertions(+), 18 deletions(-) diff --git a/package.v2.json b/package.v2.json index 152bbeb..56de172 100644 --- a/package.v2.json +++ b/package.v2.json @@ -422,7 +422,7 @@ "author": "thsrite", "level": 1, "history": { - "v1.2.1": "增加友好提示", + "v1.2.2": "修复全量同步处理非媒体文件,增加友好提示", "v1.2.0": "修复tmdb图片获取", "v1.1.9": "支持指定非媒体文件类型", "v1.1.8": "修复消息发送图片", diff --git a/plugins.v2/cloudstrmcompanion/__init__.py b/plugins.v2/cloudstrmcompanion/__init__.py index f524f94..7708c7b 100644 --- a/plugins.v2/cloudstrmcompanion/__init__.py +++ b/plugins.v2/cloudstrmcompanion/__init__.py @@ -62,7 +62,7 @@ class CloudStrmCompanion(_PluginBase): # 插件图标 plugin_icon = "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/cloudcompanion.png" # 插件版本 - plugin_version = "1.2.1" + plugin_version = "1.2.2" # 插件作者 plugin_author = "thsrite" # 作者主页 @@ -342,10 +342,6 @@ class CloudStrmCompanion(_PluginBase): local_file = str(cloud_file).replace(cloud_dir, local_dir) # 本地strm路径 target_file = str(cloud_file).replace(cloud_dir, strm_dir) - # 只处理媒体文件 - if Path(local_file).suffix.lower() not in [ext.strip() for ext in - self._rmt_mediaext.split(",")]: - continue if str(cloud_file) not in self._cloud_files: logger.info(f"扫描到新文件 {cloud_file},正在开始处理") @@ -353,13 +349,30 @@ class CloudStrmCompanion(_PluginBase): self._cloud_files.append(str(cloud_file)) __save_flag = True - # 生成strm文件内容 - strm_content = self.__format_content(format_str=format_str, - local_file=local_file, - cloud_file=str(cloud_file)) - # 生成strm文件 - self.__create_strm_file(strm_file=target_file, - strm_content=strm_content) + # 只处理媒体文件 + if Path(local_file).suffix.lower() in [ext.strip() for ext in + self._rmt_mediaext.split(",")]: + # 生成strm文件内容 + strm_content = self.__format_content(format_str=format_str, + local_file=local_file, + cloud_file=str(cloud_file)) + # 生成strm文件 + self.__create_strm_file(strm_file=target_file, + strm_content=strm_content) + else: + # 复制非媒体文件 + if self._copy_files and self._other_mediaext and Path(local_file).suffix.lower() in [ + ext.strip() for ext in self._other_mediaext.split(",")]: + os.makedirs(os.path.dirname(target_file), exist_ok=True) + shutil.copy2(str(local_file), target_file) + logger.info(f"复制非媒体文件 {str(local_file)} 到 {target_file}") + + # 复制字幕文件(独立于copy_files检查) + if self._copy_subtitles and Path(local_file).suffix.lower() in ['.srt', '.ass', '.ssa', + '.sub']: + os.makedirs(os.path.dirname(target_file), exist_ok=True) + shutil.copy2(str(local_file), target_file) + logger.info(f"复制字幕文件 {str(local_file)} 到 {target_file}") else: logger.info(f"{cloud_file} 已在缓存中!跳过处理") except Exception as e: @@ -425,11 +438,13 @@ class CloudStrmCompanion(_PluginBase): strm_content=strm_content) else: # 复制非媒体文件 - if self._copy_files and self._other_mediaext: - if Path(event_path).suffix.lower() in [ext.strip() for ext in self._other_mediaext.split(",")]: - os.makedirs(os.path.dirname(target_file), exist_ok=True) - shutil.copy2(str(event_path), target_file) - logger.info(f"复制非媒体文件 {str(event_path)} 到 {target_file}") + if self._copy_files and self._other_mediaext and Path(event_path).suffix.lower() in [ext.strip() for + ext in + self._other_mediaext.split( + ",")]: + os.makedirs(os.path.dirname(target_file), exist_ok=True) + shutil.copy2(str(event_path), target_file) + logger.info(f"复制非媒体文件 {str(event_path)} 到 {target_file}") # 复制字幕文件(独立于copy_files检查) if self._copy_subtitles and Path(event_path).suffix.lower() in ['.srt', '.ass', '.ssa', '.sub']: