diff --git a/README.md b/README.md index e6bae62..4ee5a35 100644 --- a/README.md +++ b/README.md @@ -26,14 +26,14 @@ MoviePilot三方插件市场:https://github.com/thsrite/MoviePilot-Plugins/ - [Emby观影报告 v1.5](docs%2FEmbyReporter.md) - 演员订阅 v2.1 - [短剧刮削 v3.2](docs%2FShortPlayMonitor.md) -- 云盘实时监控 v2.4.4 +- 云盘实时监控 v2.4.5 - 源文件恢复 v1.2 - [微信消息转发 v2.7](docs%2FWeChatForward.md) - 订阅下载统计 v1.5 - [自定义命令 v1.7](docs%2FCustomCommand.md) - docker自定义任务 v1.3 - 插件彻底卸载 v1.0 -- 实时软连接 v1.9.6 +- 实时软连接 v1.9.7 - 订阅规则自动填充 v2.7 - Emby元数据刷新 v1.3 - Emby媒体标签 v1.2 diff --git a/package.json b/package.json index 3717640..6bc7042 100644 --- a/package.json +++ b/package.json @@ -256,11 +256,12 @@ "name": "云盘实时监控", "description": "监控云盘目录文件变化,自动转移链接。", "labels": "云盘", - "version": "2.4.4", + "version": "2.4.5", "icon": "Linkease_A.png", "author": "thsrite", "level": 1, "history": { + "v2.4.5": "联动实时软连接插件(近媒体文件)", "v2.4.4": "修复刷新媒体库", "v2.4.3": "可选转移完刷新媒体库", "v2.4.2": "fix #65", @@ -389,11 +390,12 @@ "name": "实时软连接", "description": "监控目录文件变化,媒体文件软连接,其他文件可选复制。", "labels": "文件管理", - "version": "1.9.6", + "version": "1.9.7", "icon": "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/softlink.png", "author": "thsrite", "level": 1, "history": { + "v1.9.7": "接收云盘实时监控处理单文件", "v1.9.6": "优化log", "v1.9.5": "增强交互命令", "v1.9.4": "监控目录自定义监控模式", diff --git a/plugins/cloudassistant/__init__.py b/plugins/cloudassistant/__init__.py index 3002215..5120182 100644 --- a/plugins/cloudassistant/__init__.py +++ b/plugins/cloudassistant/__init__.py @@ -694,6 +694,7 @@ class CloudAssistant(_PluginBase): logger.info(f"开始处理媒体 {medis_title_year_season} 消息") if not media_list: + del self._medias[medis_title_year_season] continue # 获取最后更新时间 @@ -705,7 +706,8 @@ class CloudAssistant(_PluginBase): season = media_list.get("season") episodes = media_list.get("episodes") tmdbid = media_list.get("tmdbid") - if not last_update_time or not episodes: + if not last_update_time: + del self._medias[medis_title_year_season] continue # 判断剧集最后更新时间距现在是已超过10秒或者电影,发送消息 diff --git a/plugins/cloudlinkmonitor/__init__.py b/plugins/cloudlinkmonitor/__init__.py index 9405691..caeff62 100644 --- a/plugins/cloudlinkmonitor/__init__.py +++ b/plugins/cloudlinkmonitor/__init__.py @@ -60,7 +60,7 @@ class CloudLinkMonitor(_PluginBase): # 插件图标 plugin_icon = "Linkease_A.png" # 插件版本 - plugin_version = "2.4.4" + plugin_version = "2.4.5" # 插件作者 plugin_author = "thsrite" # 作者主页 @@ -86,6 +86,7 @@ class CloudLinkMonitor(_PluginBase): _scrape = False _category = False _refresh = False + _softlink = False _cron = None filetransfer = None _size = 0 @@ -131,7 +132,8 @@ class CloudLinkMonitor(_PluginBase): self._interval = config.get("interval") or 10 self._cron = config.get("cron") self._size = config.get("size") or 0 - self._auto_category = config.get("auto_category") or False + self._auto_category = config.get("auto_category") + self._softlink = config.get("softlink") # 停止现有任务 self.stop_service() @@ -251,6 +253,7 @@ class CloudLinkMonitor(_PluginBase): "interval": self._interval, "history": self._history, "category": self._category, + "softlink": self._softlink, "scrape": self._scrape, "size": self._size, "refresh": self._refresh, @@ -545,6 +548,13 @@ class CloudLinkMonitor(_PluginBase): 'transferinfo': transferinfo }) + if self._softlink: + # 通知实时软连接生成 + self.eventmanager.send_event(EventType.PluginAction, { + 'file_path': str(transferinfo.target_path), + 'action': 'softlink_file' + }) + # 移动模式删除空目录 if transfer_type == "move": for file_dir in file_path.parents: @@ -833,6 +843,22 @@ class CloudLinkMonitor(_PluginBase): }, } ] + }, + { + 'component': 'VCol', + 'props': { + 'cols': 12, + 'md': 4 + }, + 'content': [ + { + 'component': 'VSwitch', + 'props': { + 'model': 'softlink', + 'label': '联动实时软连接', + }, + } + ] } ] } @@ -991,6 +1017,27 @@ class CloudLinkMonitor(_PluginBase): ] } ] + }, + { + 'component': 'VRow', + 'content': [ + { + 'component': 'VCol', + 'props': { + 'cols': 12, + }, + 'content': [ + { + 'component': 'VAlert', + 'props': { + 'type': 'info', + 'variant': 'tonal', + 'text': '开启联动实时软连接会在监控转移后联动【实时软连接】插件生成软连接(只处理媒体文件,不处理刮削文件)。' + } + } + ] + } + ] } ] } @@ -1003,6 +1050,7 @@ class CloudLinkMonitor(_PluginBase): "category": False, "refresh": True, "auto_category": False, + "softlink": False, "mode": "fast", "transfer_type": settings.TRANSFER_TYPE, "monitor_dirs": "", diff --git a/plugins/filesoftlink/__init__.py b/plugins/filesoftlink/__init__.py index 7be2ea0..c3e14de 100644 --- a/plugins/filesoftlink/__init__.py +++ b/plugins/filesoftlink/__init__.py @@ -52,7 +52,7 @@ class FileSoftLink(_PluginBase): # 插件图标 plugin_icon = "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/softlink.png" # 插件版本 - plugin_version = "1.9.6" + plugin_version = "1.9.7" # 插件作者 plugin_author = "thsrite" # 作者主页 @@ -255,6 +255,31 @@ class FileSoftLink(_PluginBase): self.post_message(channel=event.event_data.get("channel"), title="监控目录同步完成!", userid=event.event_data.get("user")) + @eventmanager.register(EventType.PluginAction) + def softlink_file(self, event: Event = None): + if event: + event_data = event.event_data + if not event_data or event_data.get("action") != "softlink_file": + return + file_path = event_data.get("file_path") + if not file_path: + logger.error(f"缺少参数:{event_data}") + return + + # 遍历所有监控目录 + mon_path = None + for mon in self._dirconf.keys(): + if str(file_path).startswith(mon): + mon_path = mon + break + + if not mon_path: + logger.error(f"未找到文件 {file_path} 对应的监控目录") + return + + # 处理单文件 + self.__handle_file(event_path=file_path, mon_path=mon_path) + @eventmanager.register(EventType.PluginAction) def remote_sync_one(self, event: Event = None): if event: @@ -265,7 +290,7 @@ class FileSoftLink(_PluginBase): if not args: logger.error(f"缺少参数:{event_data}") return - all_args = args + all_args = args # 使用正则表达式匹配 category = None @@ -293,9 +318,10 @@ class FileSoftLink(_PluginBase): src_file = os.path.join(sroot, file_name) if Path(src_file).is_file(): self.__handle_file(event_path=str(src_file), mon_path=mon_path) - self.post_message(channel=event.event_data.get("channel"), - title=f"{all_args} 软连接完成!", - userid=event.event_data.get("user")) + if event.event_data.get("user"): + self.post_message(channel=event.event_data.get("channel"), + title=f"{all_args} 软连接完成!", + userid=event.event_data.get("user")) return return else: @@ -311,17 +337,24 @@ class FileSoftLink(_PluginBase): if not Path(args).exists(): logger.info(f"同步路径 {args} 不存在") return - logger.info(f"获取到 {args} 对应的监控目录 {mon_path}") + # 处理单文件 + if Path(args).is_file(): + self.__handle_file(event_path=str(args), mon_path=mon_path) + return + else: + # 处理指定目录 + logger.info(f"获取到 {args} 对应的监控目录 {mon_path}") - logger.info(f"开始定向处理文件夹 ...{args}") - for sroot, sdirs, sfiles in os.walk(args): - for file_name in sdirs + sfiles: - src_file = os.path.join(sroot, file_name) - if Path(str(src_file)).is_file(): - self.__handle_file(event_path=str(src_file), mon_path=mon_path) - self.post_message(channel=event.event_data.get("channel"), - title=f"{all_args} 软连接完成!", userid=event.event_data.get("user")) - return + logger.info(f"开始定向处理文件夹 ...{args}") + for sroot, sdirs, sfiles in os.walk(args): + for file_name in sdirs + sfiles: + src_file = os.path.join(sroot, file_name) + if Path(str(src_file)).is_file(): + self.__handle_file(event_path=str(src_file), mon_path=mon_path) + if event.event_data.get("user"): + self.post_message(channel=event.event_data.get("channel"), + title=f"{all_args} 软连接完成!", userid=event.event_data.get("user")) + return else: for mon_path in self._categoryconf.keys(): mon_category = self._categoryconf.get(mon_path) @@ -334,13 +367,15 @@ class FileSoftLink(_PluginBase): src_file = os.path.join(sroot, file_name) if Path(src_file).is_file(): self.__handle_file(event_path=str(src_file), mon_path=mon_path) - self.post_message(channel=event.event_data.get("channel"), - title=f"{all_args} 软连接完成!", - userid=event.event_data.get("user")) + if event.event_data.get("user"): + self.post_message(channel=event.event_data.get("channel"), + title=f"{all_args} 软连接完成!", + userid=event.event_data.get("user")) return - self.post_message(channel=event.event_data.get("channel"), - title=f"{all_args} 未检索到,请检查输入是否正确!", - userid=event.event_data.get("user")) + if event.event_data.get("user"): + self.post_message(channel=event.event_data.get("channel"), + title=f"{all_args} 未检索到,请检查输入是否正确!", + userid=event.event_data.get("user")) def sync_all(self): """