diff --git a/README.md b/README.md index 17349d4..864c561 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ MoviePilot三方插件市场:https://github.com/thsrite/MoviePilot-Plugins/ - [站点数据统计 1.4](docs%2FSiteStatisticNoMsg.md) (无未读消息版本)(废弃) - [站点未读消息 1.2](docs%2FSiteUnreadMsg.md) -- [云盘Strm生成 3.0](docs%2FCloudStrm.md) +- [云盘Strm生成 3.6](docs%2FCloudStrm.md) - [Strm文件模式转换 1.0](docs%2FStrmConvert.md) - [清理订阅缓存 1.0](docs%2FSubscribeClear.md) - [添加种子下载 1.0](docs%2FDownloadTorrent.md) diff --git a/docs/CloudStrm.md b/docs/CloudStrm.md index 8d2dbc9..73d64bc 100644 --- a/docs/CloudStrm.md +++ b/docs/CloudStrm.md @@ -2,6 +2,7 @@ ### 更新记录 +- 3.6 加快处理速度 - 3.5 fix bug - 3.4 交互命令 - 3.3 fix bug diff --git a/package.json b/package.json index f3f5f5e..55c6384 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "CloudStrm": { "name": "云盘Strm生成", "description": "监控文件创建,生成Strm文件。", - "version": "3.5", + "version": "3.6", "icon": "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/create.png", "author": "thsrite", "level": 1 diff --git a/plugins/cloudstrm/__init__.py b/plugins/cloudstrm/__init__.py index a56d118..6e97527 100644 --- a/plugins/cloudstrm/__init__.py +++ b/plugins/cloudstrm/__init__.py @@ -16,6 +16,7 @@ from apscheduler.triggers.cron import CronTrigger from app.log import logger from app.plugins import _PluginBase from app.core.config import settings +from app.utils.system import SystemUtils class CloudStrm(_PluginBase): @@ -26,7 +27,7 @@ class CloudStrm(_PluginBase): # 插件图标 plugin_icon = "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/create.png" # 插件版本 - plugin_version = "3.5" + plugin_version = "3.6" # 插件作者 plugin_author = "thsrite" # 作者主页 @@ -199,35 +200,30 @@ class CloudStrm(_PluginBase): __save_flag = False for source_dir in self._dirconf.keys(): logger.info(f"正在处理监控文件 {source_dir}") - for root, dirs, files in os.walk(source_dir): - # 如果遇到名为'extrafanart'的文件夹,则跳过处理该文件夹,继续处理其他文件夹 - if "extrafanart" in dirs: - dirs.remove("extrafanart") + # 遍历获取下载目录所有文件 + file_paths = SystemUtils.list_files(directory=Path(source_dir), + extensions=['.*'] if self._copy_files else settings.RMT_MEDIAEXT) + logger.info( + f"获取目录 {source_dir} {'所有类型文件' if self._copy_files else '媒体类型文件'} 文件数量:{len(file_paths)}") + for file in file_paths: + source_file = str(file) + # 回收站及隐藏的文件不处理 + if (source_file.find("/@Recycle") != -1 + or source_file.find("/#recycle") != -1 + or source_file.find("/.") != -1 + or source_file.find("/@eaDir") != -1): + logger.info(f"{source_file} 是回收站或隐藏的文件,跳过处理") + continue - # 处理文件 - for file in files: - source_file = os.path.join(root, file) - # 回收站及隐藏的文件不处理 - if (source_file.find("/@Recycle") != -1 - or source_file.find("/#recycle") != -1 - or source_file.find("/.") != -1 - or source_file.find("/@eaDir") != -1): - logger.info(f"{source_file} 是回收站或隐藏的文件,跳过处理") - continue - - # 不复制非媒体文件时直接过滤掉非媒体文件 - if not self._copy_files and not file.lower().endswith(self._video_formats): - continue - - if source_file not in self.__cloud_files: - logger.info(f"扫描到新文件 {source_file},正在开始处理") - # 云盘文件json新增 - self.__cloud_files.append(source_file) - # 扫描云盘文件,判断是否有对应strm - self.__strm(source_file) - __save_flag = True - else: - logger.debug(f"{source_file} 已在缓存中!跳过处理") + if source_file not in self.__cloud_files: + logger.info(f"扫描到新文件 {source_file},正在开始处理") + # 云盘文件json新增 + self.__cloud_files.append(source_file) + # 扫描云盘文件,判断是否有对应strm + self.__strm(source_file) + __save_flag = True + else: + logger.debug(f"{source_file} 已在缓存中!跳过处理") # 重新保存json文件 if __save_flag: @@ -246,31 +242,27 @@ class CloudStrm(_PluginBase): # init for source_dir in self._dirconf.keys(): logger.info(f"正在处理监控文件 {source_dir}") - for root, dirs, files in os.walk(source_dir): - # 如果遇到名为'extrafanart'的文件夹,则跳过处理该文件夹,继续处理其他文件夹 - if "extrafanart" in dirs: - dirs.remove("extrafanart") - + # 遍历获取下载目录所有文件 + file_paths = SystemUtils.list_files(directory=Path(source_dir), + extensions=['.*'] if self._copy_files else settings.RMT_MEDIAEXT) + logger.info( + f"初始化获取目录 {source_dir} {'所有类型文件' if self._copy_files else '媒体类型文件'} 文件数量:{len(file_paths)}") + for file in file_paths: # 处理文件 - for file in files: - source_file = os.path.join(root, file) - # 回收站及隐藏的文件不处理 - if (source_file.find("/@Recycle") != -1 - or source_file.find("/#recycle") != -1 - or source_file.find("/.") != -1 - or source_file.find("/@eaDir") != -1): - logger.info(f"{source_file} 是回收站或隐藏的文件,跳过处理") - continue + source_file = str(file) + # 回收站及隐藏的文件不处理 + if (source_file.find("/@Recycle") != -1 + or source_file.find("/#recycle") != -1 + or source_file.find("/.") != -1 + or source_file.find("/@eaDir") != -1): + logger.info(f"{source_file} 是回收站或隐藏的文件,跳过处理") + continue - # 不复制非媒体文件时直接过滤掉非媒体文件 - if not self._copy_files and not file.lower().endswith(self._video_formats): - continue - - logger.info(f"扫描到新文件 {source_file},正在开始处理") - # 云盘文件json新增 - self.__cloud_files.append(source_file) - # 扫描云盘文件,判断是否有对应strm - self.__strm(source_file) + logger.info(f"扫描到新文件 {source_file},正在开始处理") + # 云盘文件json新增 + self.__cloud_files.append(source_file) + # 扫描云盘文件,判断是否有对应strm + self.__strm(source_file) # 写入本地文件 if self.__cloud_files: