diff --git a/command.py b/command.py index dbdd803..d844e54 100644 --- a/command.py +++ b/command.py @@ -136,9 +136,11 @@ def update_server(): def mdc_main( path: str, config_ini=None, + target_folder=None, ): - target_folder = config.target_folder + if not target_folder: + target_folder = config.target_folder proxy = config.proxies["http"] command = ["./mdc_ng", "-p", path] @@ -160,7 +162,7 @@ def mdc_main( ) -def mdc_dir(path: str): +def mdc_dir(path: str, target_folder=None): videos = collect_videos(path) if len(videos) > 0: _LOGGER.info("[MDC] 视频文件检测到: %s" % videos) @@ -171,7 +173,7 @@ def mdc_dir(path: str): for video in videos: _LOGGER.info("[MDC] 开始处理视频文件: %s" % video) try: - mdc_main(video) + mdc_main(video, target_folder=target_folder) except Exception as e: _LOGGER.error("[MDC] 处理视频文件出错: %s" % video) _LOGGER.error(e) diff --git a/config.py b/config.py index 85c43e2..f189e0b 100644 --- a/config.py +++ b/config.py @@ -16,12 +16,12 @@ target_folder = "" -def init_config(web_config: dict): +def init_config(web_config: dict[str, str]): global watch_folder, target_folder, proxies to_watch = web_config.get("watch_folder") if to_watch: - watch_folder = to_watch.split(",") + watch_folder = [folder.split(":") for folder in to_watch.split(",")] logging.info("MDC插件已启用, 监视文件夹: %s" % watch_folder) target_folder = web_config.get("target_folder") or "" diff --git a/event.py b/event.py index 7c353b8..cc54b83 100644 --- a/event.py +++ b/event.py @@ -44,14 +44,18 @@ def on_event(ctx: PluginContext, event_type: str, data: Dict): _LOGGER.info("[MDC事件] watch_folder: %s " % config.watch_folder) flag = False + target_folder = None # 检查是否匹配监控目录配置 - for dir in config.watch_folder: + for folders in config.watch_folder: + dir = folders[0] if save_path.startswith(dir): flag = True + if len(folders) > 1: + target_folder = folders[1] break if not flag: return _LOGGER.info("[MDC事件] 下载地址与监控目录匹配: %s, 开始执行刮削" % save_path) - mdc_dir(save_path) + mdc_dir(save_path, target_folder) diff --git a/manifest.json b/manifest.json index 6c1e81a..6c5bc51 100755 --- a/manifest.json +++ b/manifest.json @@ -23,13 +23,13 @@ { "fieldName": "watch_folder", "fieldType": "String", - "label": "监控路径,逗号分隔", + "label": "监控路径,英文逗号分隔. 在每个监控路径后可以用英文冒号(:)附加一个该路径对应的目标路径", "defaultValue": "" }, { "fieldName": "target_folder", "fieldType": "String", - "label": "刮削整理目标路径", + "label": "默认刮削整理目标路径", "defaultValue": "" } ]