diff --git a/README.md b/README.md index 4e0e7f1..9a1d43c 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ MoviePilot三方插件市场:https://github.com/thsrite/MoviePilot-Plugins/ - [站点数据统计 1.0](docs%2FSiteStatisticNoMsg.md) (无未读消息版本) - [站点未读消息 1.2](docs%2FSiteUnreadMsg.md) -- [云盘Strm生成 2.0](docs%2FCloudStrm.md) +- [云盘Strm生成 2.1](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 b7d080c..f67bcb0 100644 --- a/docs/CloudStrm.md +++ b/docs/CloudStrm.md @@ -2,6 +2,7 @@ ### 更新记录 +- 2.1 增加复制非媒体文件开关 - 2.0 修复重复执行的问题 - 1.7 支持m2ts视频格式 - 1.6 支持开启监控延迟 diff --git a/package.json b/package.json index a89512b..5fabb16 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "CloudStrm": { "name": "云盘Strm生成", "description": "监控文件创建,生成Strm文件。", - "version": "1.7", + "version": "2.1", "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 5dfb6b8..dc179ba 100644 --- a/plugins/cloudstrm/__init__.py +++ b/plugins/cloudstrm/__init__.py @@ -44,7 +44,7 @@ class CloudStrm(_PluginBase): # 插件图标 plugin_icon = "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/create.png" # 插件版本 - plugin_version = "2.0" + plugin_version = "2.1" # 插件作者 plugin_author = "thsrite" # 作者主页 @@ -60,6 +60,7 @@ class CloudStrm(_PluginBase): _enabled = False _monitor_confs = None _onlyonce = False + _copy_files = False _relay = 3 _observer = [] _video_formats = ('.mp4', '.avi', '.rmvb', '.wmv', '.mov', '.mkv', '.flv', '.ts', '.webm', '.iso', '.mpg', '.m2ts') @@ -86,6 +87,7 @@ class CloudStrm(_PluginBase): if config: self._enabled = config.get("enabled") self._onlyonce = config.get("onlyonce") + self._copy_files = config.get("copy_files") self._monitor_confs = config.get("monitor_confs") self._relay = config.get("relay") or 3 @@ -252,19 +254,14 @@ class CloudStrm(_PluginBase): # 视频文件创建.strm文件 if event_path.lower().endswith(self._video_formats): - # 如果视频文件小于1MB,则直接复制,不创建.strm文件 - if os.path.getsize(event_path) < 1024 * 1024: - shutil.copy2(event_path, dest_file) - logger.info(f"复制视频文件 {event_path} 到 {dest_file}") - else: - # 创建.strm文件 - self.__create_strm_file(dest_file=dest_file, - dest_dir=dest_dir, - source_file=event_path, - library_dir=library_dir, - cloud_type=cloud_type, - cloud_path=cloud_path, - cloud_url=cloud_url) + # 创建.strm文件 + self.__create_strm_file(dest_file=dest_file, + dest_dir=dest_dir, + source_file=event_path, + library_dir=library_dir, + cloud_type=cloud_type, + cloud_path=cloud_path, + cloud_url=cloud_url) else: # 其他nfo、jpg等复制文件 shutil.copy2(event_path, dest_file) @@ -348,9 +345,10 @@ class CloudStrm(_PluginBase): cloud_path=cloud_path, cloud_url=cloud_url) else: - # 复制文件 - logger.info(f"复制其他文件到:::{dest_file}") - shutil.copy2(source_file, dest_file) + if self._copy_files: + # 复制文件 + logger.info(f"复制其他文件到:::{dest_file}") + shutil.copy2(source_file, dest_file) @staticmethod def __create_strm_file(dest_file: str, dest_dir: str, source_file: str, library_dir: str = None, @@ -413,6 +411,7 @@ class CloudStrm(_PluginBase): self.update_config({ "enabled": self._enabled, "onlyonce": self._onlyonce, + "copy_files": self._copy_files, "relay": self._relay, "monitor_confs": self._monitor_confs }) @@ -515,6 +514,27 @@ class CloudStrm(_PluginBase): } ] }, + { + 'component': 'VRow', + 'content': [ + { + 'component': 'VCol', + 'props': { + 'cols': 12, + 'md': 6 + }, + 'content': [ + { + 'component': 'VSwitch', + 'props': { + 'model': 'copy_files', + 'label': '复制非媒体文件', + } + } + ] + }, + ] + }, { 'component': 'VRow', 'content': [ @@ -656,6 +676,7 @@ class CloudStrm(_PluginBase): "enabled": False, "relay": 3, "onlyonce": False, + "copy_files": False, "monitor_confs": "" }