From bebbb9bd292293d22707b1d4d62a9ff44458e7b6 Mon Sep 17 00:00:00 2001 From: thsrite Date: Thu, 1 Aug 2024 09:35:02 +0800 Subject: [PATCH] fix --- docs/CloudAssistant.md | 1 + plugins/cloudassistant/__init__.py | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/docs/CloudAssistant.md b/docs/CloudAssistant.md index 4f9845f..6e36f03 100644 --- a/docs/CloudAssistant.md +++ b/docs/CloudAssistant.md @@ -151,6 +151,7 @@ cd2方式上传--strm回本地(暂时移除) - only_media:是否只监控媒体文件 - overwrite:是否覆盖已存在云盘文件 - upload_cloud: 是否上传到云盘, false则直接软连接或者strm回本地 +- notify_url: 软连接或者strm回本地成功后,通知接口地址,post请求参数:`{"path": "文件路径", "type": "add"}` - strm配置具体看[CloudStrm.md](CloudStrm.md) - library_dir:strm模式下,媒体服务器内源文件路径 diff --git a/plugins/cloudassistant/__init__.py b/plugins/cloudassistant/__init__.py index 157e973..82adf36 100644 --- a/plugins/cloudassistant/__init__.py +++ b/plugins/cloudassistant/__init__.py @@ -123,7 +123,8 @@ class CloudAssistant(_PluginBase): "src_preserve_hierarchy": 0, "only_media": "true", "overwrite": "false", - "upload_cloud": "true" + "upload_cloud": "true", + "notify_url": "" } ] } @@ -340,7 +341,7 @@ class CloudAssistant(_PluginBase): 立即运行一次,全量同步目录中所有文件 """ logger.info("云盘助手全量同步监控目录 ...") - + # 遍历所有监控目录 for mon_path in self._dirconf.keys(): video_files = [] @@ -351,12 +352,12 @@ class CloudAssistant(_PluginBase): file_path = os.path.join(root, name) if Path(str(file_path)).is_file(): if Path(str(file_path)).suffix.lower() in [ext.strip() for ext in - self._rmt_mediaext.split(",")]: + self._rmt_mediaext.split(",")]: video_files.append(file_path) else: other_files.append(file_path) - # Then, handle other files + # Then, handle other files for other_file in other_files: self.__handle_file(event_path=str(other_file), mon_path=mon_path) # First, handle video files @@ -517,6 +518,11 @@ class CloudAssistant(_PluginBase): cloud_url=monitor_dir.get("cloud_url"), cloud_scheme=monitor_dir.get("cloud_scheme")) + if monitor_dir.get("notify_url"): + RequestUtils(content_type="application/json").post(url=monitor_dir.get("notify_url"), json={ + "path": str(mount_file), + "type": "add" + }) else: # 其他nfo、jpg等复制文件 SystemUtils.copy(file_path, Path(target_return_file))