├── .github └── workflows │ └── release.yml ├── .gitignore ├── .venv ├── CHANGELOG.md ├── README.md ├── __init__.py ├── command.py ├── config.ini ├── config.py ├── event.py ├── logo.png └── manifest.json /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | permissions: write-all 4 | 5 | on: 6 | push: 7 | branches: [ "main" ] 8 | tags: 9 | - "v*.*.*" 10 | 11 | jobs: 12 | release: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - name: Checkout 16 | uses: actions/checkout@v3 17 | 18 | - name: Release-PR 19 | uses: google-github-actions/release-please-action@v3 20 | with: 21 | release-type: simple 22 | token: ${{ secrets.PAT_RELEASE }} 23 | pull-request-title-pattern: "chore${scope}: release ${version}" 24 | extra-files: manifest.json 25 | 26 | - name: Release-latest 27 | uses: softprops/action-gh-release@v1 28 | if: "!startsWith(github.ref, 'refs/tags/')" 29 | with: 30 | tag_name: latest 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | libmdc_ng.so 2 | **/*/__pycache__ 3 | -------------------------------------------------------------------------------- /.venv: -------------------------------------------------------------------------------- 1 | mbot-mdc 2 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## [1.8.0](https://github.com/mdc-ng/mdc_mbot_plugin/compare/v1.7.0...v1.8.0) (2024-05-30) 4 | 5 | 6 | ### Features 7 | 8 | * 添加复制模式和相应选项 ([a6bef30](https://github.com/mdc-ng/mdc_mbot_plugin/commit/a6bef30a309089776bc7ea43aaaeb53cde06dc11)) 9 | 10 | ## [1.7.0](https://github.com/mdc-ng/mdc_mbot_plugin/compare/v1.6.0...v1.7.0) (2023-03-09) 11 | 12 | 13 | ### Features 14 | 15 | * 增加多目录监控刮削功能 ([85c8f6b](https://github.com/mdc-ng/mdc_mbot_plugin/commit/85c8f6b5a2cc8b8c396b85f82fcf6bde7ec6e0ed)) 16 | 17 | ## [1.6.0](https://github.com/mdc-ng/mdc_mbot_plugin/compare/v1.5.0...v1.6.0) (2023-03-08) 18 | 19 | 20 | ### Features 21 | 22 | * 后端服务随MR自动启动 ([d522051](https://github.com/mdc-ng/mdc_mbot_plugin/commit/d5220516994d14edb326b4c3192b45635d1a4888)) 23 | 24 | ## [1.5.0](https://github.com/mdc-ng/mdc_mbot_plugin/compare/v1.4.1...v1.5.0) (2023-03-02) 25 | 26 | 27 | ### Features 28 | 29 | * MR使用独立插件配置,与MDC server配置分离 ([c9b4ddc](https://github.com/mdc-ng/mdc_mbot_plugin/commit/c9b4ddc91dd69e05874de08f942796c2235fd8e3)) 30 | 31 | ## [1.4.1](https://github.com/mdc-ng/mdc_mbot_plugin/compare/v1.4.0...v1.4.1) (2023-03-02) 32 | 33 | 34 | ### Bug Fixes 35 | 36 | * 去除冗余插件配置 ([c5d5630](https://github.com/mdc-ng/mdc_mbot_plugin/commit/c5d56304e06e96052c2ce34c3581c96b5492be67)) 37 | 38 | ## [1.4.0](https://github.com/mdc-ng/mdc_mbot_plugin/compare/v1.3.0...v1.4.0) (2023-03-02) 39 | 40 | 41 | ### Features 42 | 43 | * 添加MDC服务端相关指令 ([08e66d2](https://github.com/mdc-ng/mdc_mbot_plugin/commit/08e66d2ead630fde175a261c78f94aae1a222182)) 44 | 45 | ## [1.3.0](https://github.com/mdc-ng/mdc_mbot_plugin/compare/v1.2.0...v1.3.0) (2023-02-14) 46 | 47 | 48 | ### Features 49 | 50 | * 添加logo和项目链接 ([d2cefa1](https://github.com/mdc-ng/mdc_mbot_plugin/commit/d2cefa15f9f9c35af91993dd162af78fadc0dae9)) 51 | 52 | ## [1.2.0](https://github.com/mdc-ng/mdc_mbot_plugin/compare/v1.1.1...v1.2.0) (2023-02-08) 53 | 54 | 55 | ### Features 56 | 57 | * 添加手动执行快捷指令 ([5073cb4](https://github.com/mdc-ng/mdc_mbot_plugin/commit/5073cb4dff2080246264a07da995670cef62974b)) 58 | 59 | 60 | ### Bug Fixes 61 | 62 | * typo ([2712002](https://github.com/mdc-ng/mdc_mbot_plugin/commit/2712002adb2f02d85ebd78a84dcd216296b51bff)) 63 | * 优化初始化逻辑,不再自动拉取基础库 ([fc8071c](https://github.com/mdc-ng/mdc_mbot_plugin/commit/fc8071c4b3b4412a8a1efa1f8ac1e5cdcdcab1fc)) 64 | 65 | ## [1.1.1](https://github.com/mdc-ng/mdc_mbot_plugin/compare/v1.1.0...v1.1.1) (2023-02-08) 66 | 67 | 68 | ### Bug Fixes 69 | 70 | * 添加MR版本依赖 ([c00dcd8](https://github.com/mdc-ng/mdc_mbot_plugin/commit/c00dcd8146216d8e250aeb67cdaeb187eb9c42ee)) 71 | 72 | ## [1.1.0](https://github.com/mdc-ng/mdc_mbot_plugin/compare/v1.0.1...v1.1.0) (2023-02-08) 73 | 74 | 75 | ### Features 76 | 77 | * 更新mdc架构 ([4adfdf3](https://github.com/mdc-ng/mdc_mbot_plugin/commit/4adfdf3a86f91bd50b552a4d8550a7240d4e2f86)) 78 | 79 | ## [1.0.1](https://github.com/mdc-ng/mdc_mbot_plugin/compare/v1.0.0...v1.0.1) (2023-02-07) 80 | 81 | 82 | ### Bug Fixes 83 | 84 | * 测试CI自动更新版本号 ([9af0016](https://github.com/mdc-ng/mdc_mbot_plugin/commit/9af0016094aad1b98239c9a6acf40e77fc99b9db)) 85 | 86 | ## 1.0.0 (2023-02-07) 87 | 88 | 89 | ### Features 90 | 91 | * repo init ([57e8d56](https://github.com/mdc-ng/mdc_mbot_plugin/commit/57e8d567ef3659dd478159f4f20c1b38ee0f69ab)) 92 | * 支持网页端配置代理和目标路径 ([6997fb1](https://github.com/mdc-ng/mdc_mbot_plugin/commit/6997fb17ce07f1754bc27c563419d1badea4163b)) 93 | * 添加ts后缀支持 ([f58bd0e](https://github.com/mdc-ng/mdc_mbot_plugin/commit/f58bd0e041f2da57a568d99c054d50994d62a4cf)) 94 | * 添加水印配置 ([418591e](https://github.com/mdc-ng/mdc_mbot_plugin/commit/418591e72f04ccda09db15cb723c7749ae296821)) 95 | * 添加监控目录自动刮削功能 ([aaf2635](https://github.com/mdc-ng/mdc_mbot_plugin/commit/aaf2635f172e2b1da2f9a7c65166f896c10c76d1)) 96 | 97 | 98 | ### Bug Fixes 99 | 100 | * 修复初始化 bug ([74b0e6f](https://github.com/mdc-ng/mdc_mbot_plugin/commit/74b0e6fec508086628c63d938fb12e7839351eff)) 101 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2024/06/14 本项目停止维护,请移步 [mdc-ng 应用版](https://github.com/mdc-ng/mdc-ng),使用目录监控代替此插件功能。应用版已更新模式选择、演员刮削等等更多功能 2 | ---- 3 | 4 | # mdc_mbot_plugin 5 | Yet another MovieBot plugin 6 | 7 | [![GitHub manifest version](https://img.shields.io/github/manifest-json/v/mdc-ng/mdc_mbot_plugin?label=plugin)](https://github.com/mdc-ng/mdc_mbot_plugin/releases) 8 | [![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/mdc-ng/mdc-ng?color=orange&label=mdc-ng)](https://github.com/mdc-ng/mdc-ng/releases) 9 | 10 | ## Features 11 | - [x] 高性能刮削器 12 | - [x] 监控下载目录,下载完成自动刮削入库 13 | - [x] 支持图片添加标签水印 14 | - [x] 存量整理 15 | - [x] 可视化界面 16 | - [ ] 演员图片 17 | 18 | ## Usage 19 | ### 工作流程 20 | 硬链后刮削,无需担心做种问题,全流程如下: 21 | 1. 识别影片ID 22 | 2. 抓取元数据 23 | 3. 创建目标目录 24 | 4. 下载、处理图片 25 | 5. 硬链接视频以及自带的字幕文件到目标目录 26 | 6. 生成nfo文件 27 | 28 | ### 安装与使用 29 | 1. 在 [Release](https://github.com/mdc-ng/mdc_mbot_plugin/releases) 页面下载最新版本插件压缩包 mdc_mbot_plugin-${version}.zip 30 | 2. 解压缩并将插件文件夹重命名为 mdc_mbot_plugin,丢到容器的 plugins 目录 31 | 3. 重启容器 32 | 4. 进入 moviebot 的插件管理 - 我的插件页面,对 MDC 插件进行配置 33 | 5. 多个监控、刮削目录配置方法如下图。以图中的配置为例: 34 | 1. 监控 /misc/downloads 和 /tmp 两个下载目录 35 | 2. 下载到 /misc/downloads 的视频会刮削保存到/ misc/test 36 | 3. 下载到 /tmp 的视频会刮削到 /tmp/adult 37 | image 38 | 39 | 注意:如果配置了监控目录,需要在MR的应用设置 - 下载设置 - 媒体文件夹中添加该目录,只要保持“下载路径装载到容器的路径”一项与MDC监控目录中的配置一致即可,其余随意填写无影响 40 | 41 | 5. 代理配好后,在插件管理 - 快捷功能中执行“更新MDC”,等待执行成功 42 | 6. 若更新MDC失败,通常是与github网络连接性问题,请检查代理是否配置正确 43 | 7. 日志中若出现 “MDC version: xxx”:恭喜你,插件配置完成! 44 | 8. MDC的主要功能由核心库提供: https://github.com/mdc-ng/mdc-ng/releases 45 | 46 | 请关注核心库的版本发布。可执行5~7步骤单独更新内核,以获得MDC的最新特性 47 | 48 | ### 作为基础库 49 | ```python 50 | # 其他插件中对 MDC 的调用方式示例 51 | def mdc_command(video, config_path): 52 | from ..mdc_mbot_plugin import mdc_main 53 | 54 | # video: 必填,视频的绝对路径,如 /nas/media/xxx.mp4 55 | # config_path: 可选,自定义配置文件的绝对路径。不传递则会使用默认config.ini 56 | mdc_main(video, config_path) 57 | ``` 58 | 59 | ## Web UI 60 | v1.4.0版本后,插件整合了 MDC-NG Web UI 套件,增强了存量整理、可视化刮削以及配置管理等功能。在插件管理页面进行服务端的下载更新和启动: 61 | 62 | 63 | 64 | ### Usage 65 | 1. MDC server 默认使用9208端口,需要先在MovieBot容器添加相应的端口映射 66 | 2. 点击”更新MDC“,插件会同时更新MDC lib与server组件 67 | 3. 更新完成后,点击”启动/停止服务端"进行服务启动 68 | 4. 在浏览器访问 <容器IP>:9208 进入 Web 界面 69 | 5. MDC server 支持容器化部署方式,最新动态请关注容器版本发布页:https://hub.docker.com/repository/docker/mdcng/mdc/general 70 | 6. 当前版本仍在开发阶段,可能存在不少bug,遇到问题请提issue 71 | 72 | 73 | ## 已知问题 74 | 1. 在当前版本MR(v1.9.xx)进行 **网页端** 搜索或订阅下载的视频,目标目录中会同时存在MR原样硬链过去的文件和插件刮削结果硬链,下载器直接提交的不受影响。MR后续会支持关闭指定媒体目录的自动硬链,此问题即可随之解决 75 | 76 | ## 支持一下 77 | 你可以送我一杯咖啡,以表示对这个项目的支持😉 78 | 79 | 80 | -------------------------------------------------------------------------------- /__init__.py: -------------------------------------------------------------------------------- 1 | import logging 2 | from mbot.core.plugins import ( 3 | plugin, 4 | PluginMeta, 5 | ) 6 | from typing import Dict, Any 7 | from .command import * 8 | from .config import * 9 | from .event import * 10 | 11 | _LOGGER = logging.getLogger(__name__) 12 | logging.basicConfig(level=logging.INFO) 13 | 14 | 15 | @plugin.after_setup 16 | def after_setup(plugin_meta: PluginMeta, config: Dict[str, Any]): 17 | init_config(config) 18 | 19 | try: 20 | if os.path.isfile(bin_path): 21 | run_command( 22 | [ 23 | "./mdc_ng", 24 | "-v", 25 | ], 26 | True, 27 | cwd=pathlib.Path(__file__).parent.absolute(), 28 | ) 29 | else: 30 | _LOGGER.error("MDC基础库加载失败, 请尝试在插件管理页面配置代理、手动更新MDC lib") 31 | 32 | if os.path.isfile(backend_path): 33 | start_server() 34 | 35 | except Exception as e: 36 | _LOGGER.error(e) 37 | _LOGGER.error("MDC基础库加载失败, 请尝试在插件管理页面配置代理、手动更新MDC lib") 38 | -------------------------------------------------------------------------------- /command.py: -------------------------------------------------------------------------------- 1 | import logging 2 | import subprocess 3 | import pathlib 4 | import os 5 | import requests 6 | import shutil 7 | from mbot.core.params import ArgSchema, ArgType 8 | from mbot.core.plugins import ( 9 | plugin, 10 | PluginCommandContext, 11 | PluginCommandResponse, 12 | ) 13 | from mbot.openapi import mbot_api 14 | from . import config 15 | 16 | 17 | server = mbot_api 18 | _LOGGER = logging.getLogger(__name__) 19 | 20 | bin_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "mdc_ng") 21 | bin_path_new = bin_path + ".new" 22 | 23 | backend_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "backend") 24 | backend_path_new = backend_path + ".new" 25 | 26 | mdc_server = None 27 | 28 | 29 | @plugin.command( 30 | name="update", 31 | title="更新MDC", 32 | desc="拉取最新MDC核心库和后端服务", 33 | icon="AlarmOn", 34 | run_in_background=True, 35 | ) 36 | def update(ctx: PluginCommandContext): 37 | update_bin() 38 | update_server() 39 | 40 | _LOGGER.info("MDC更新成功") 41 | return PluginCommandResponse(True, "更新成功") 42 | 43 | 44 | @plugin.command( 45 | name="start_mdc_server", 46 | title="启动/停止MDC服务端", 47 | desc="启动/停止MDC服务端", 48 | icon="AlarmOn", 49 | run_in_background=True, 50 | ) 51 | def start_mdc_server(ctx: PluginCommandContext): 52 | global mdc_server 53 | 54 | if not mdc_server: 55 | start_server() 56 | else: 57 | stop_server() 58 | 59 | return PluginCommandResponse(True, "启动成功,请通过9208端口访问Web UI") 60 | 61 | 62 | @plugin.command( 63 | name="mdc_manual", 64 | title="MDC手动执行", 65 | desc="指定目录或视频文件进行刮削", 66 | icon="", 67 | run_in_background=True, 68 | ) 69 | def mdc_test( 70 | ctx: PluginCommandContext, path: ArgSchema(ArgType.String, "刮削路径", "") 71 | ): 72 | try: 73 | mdc_dir(path) 74 | except Exception as e: 75 | _LOGGER.error(e, exc_info=True) 76 | return PluginCommandResponse(False, f"一键刮削成功") 77 | return PluginCommandResponse(True, f"一键刮削失败") 78 | 79 | 80 | def update_bin(): 81 | download_file( 82 | "https://github.com/mdc-ng/mdc-ng/releases/download/latest/mdc_ng", 83 | bin_path_new, 84 | ) 85 | try: 86 | os.remove(bin_path) 87 | except: 88 | pass 89 | os.rename(bin_path_new, bin_path) 90 | run_command( 91 | [ 92 | "chmod", 93 | "+x", 94 | "mdc_ng", 95 | ], 96 | False, 97 | cwd=pathlib.Path(__file__).parent.absolute(), 98 | ) 99 | run_command( 100 | [ 101 | "./mdc_ng", 102 | "-v", 103 | ], 104 | True, 105 | cwd=pathlib.Path(__file__).parent.absolute(), 106 | ) 107 | 108 | 109 | def update_server(): 110 | download_file( 111 | "https://github.com/mdc-ng/mdc-ng/releases/download/latest/backend", 112 | backend_path_new, 113 | ) 114 | try: 115 | os.remove(backend_path) 116 | except: 117 | pass 118 | os.rename(backend_path_new, backend_path) 119 | run_command( 120 | [ 121 | "chmod", 122 | "+x", 123 | "backend", 124 | ], 125 | False, 126 | cwd=pathlib.Path(__file__).parent.absolute(), 127 | ) 128 | run_command( 129 | [ 130 | "./backend", 131 | "-v", 132 | ], 133 | True, 134 | cwd=pathlib.Path(__file__).parent.absolute(), 135 | ) 136 | 137 | 138 | def mdc_main( 139 | path: str, 140 | config_ini=None, 141 | target_folder=None, 142 | link_mode=None, 143 | ): 144 | if not target_folder: 145 | target_folder = config.target_folder 146 | if not link_mode: 147 | link_mode = config.link_mode 148 | proxy = config.proxies["http"] 149 | 150 | command = ["./mdc_ng", "-p", path] 151 | 152 | if config_ini: 153 | command.extend(["-c", config_ini]) 154 | if target_folder: 155 | command.extend(["-t", target_folder]) 156 | if proxy: 157 | command.extend(["--proxy", proxy]) 158 | if link_mode: 159 | command.extend(["-l", link_mode]) 160 | 161 | _LOGGER.info(command) 162 | 163 | run_command( 164 | command, 165 | True, 166 | cwd=pathlib.Path(__file__).parent.absolute(), 167 | env={"RUST_LOG": "mdc_ng=info"}, 168 | ) 169 | 170 | 171 | def mdc_dir(path: str, target_folder=None): 172 | videos = collect_videos(path) 173 | if len(videos) > 0: 174 | _LOGGER.info("[MDC] 视频文件检测到: %s" % videos) 175 | 176 | if len(videos) > 10: 177 | _LOGGER.info("[MDC] 视频文件数量多于10个,不处理") 178 | 179 | for video in videos: 180 | _LOGGER.info("[MDC] 开始处理视频文件: %s" % video) 181 | try: 182 | mdc_main(video, target_folder=target_folder) 183 | except Exception as e: 184 | _LOGGER.error("[MDC] 处理视频文件出错: %s" % video) 185 | _LOGGER.error(e) 186 | continue 187 | _LOGGER.info("[MDC] 处理视频文件完成: %s" % video) 188 | 189 | 190 | def collect_videos(path: str): 191 | if not path: 192 | return [] 193 | videos = [] 194 | if os.path.isdir(path): 195 | for file in os.listdir(path): 196 | videos.extend(collect_videos(os.path.join(path, file))) 197 | return videos 198 | elif os.path.splitext(path)[1].lower() in [ 199 | ".mp4", 200 | ".avi", 201 | ".rmvb", 202 | ".wmv", 203 | ".mov", 204 | ".mkv", 205 | ".webm", 206 | ".iso", 207 | ".mpg", 208 | ".m4v", 209 | ".ts", 210 | ]: 211 | return [path] 212 | else: 213 | return [] 214 | 215 | 216 | def download_file(url, name): 217 | with requests.get(url, proxies=config.proxies, stream=True) as r: 218 | with open(name, "wb") as f: 219 | shutil.copyfileobj(r.raw, f) 220 | 221 | return name 222 | 223 | 224 | def run_command(command, capture, **kwargs): 225 | """Run a command while printing the live output""" 226 | process = subprocess.Popen( 227 | command, 228 | stdout=subprocess.PIPE, 229 | stderr=subprocess.STDOUT, 230 | **kwargs, 231 | ) 232 | while True: # Could be more pythonic with := in Python3.8+ 233 | line = process.stdout.readline() 234 | if not line and process.poll() is not None: 235 | break 236 | if capture: 237 | _LOGGER.info(line.decode().strip()) 238 | 239 | 240 | def start_server(): 241 | global mdc_server 242 | if not mdc_server: 243 | mdc_server = subprocess.Popen( 244 | [ 245 | "./backend", 246 | "-p", 247 | "9208", 248 | ], 249 | cwd=pathlib.Path(__file__).parent.absolute(), 250 | ) 251 | 252 | 253 | def stop_server(): 254 | global mdc_server 255 | if mdc_server: 256 | mdc_server.terminate() 257 | mdc_server = None 258 | -------------------------------------------------------------------------------- /config.ini: -------------------------------------------------------------------------------- 1 | [common] 2 | target_folder = /misc/adult 3 | 4 | [proxy] 5 | proxy = 6 | 7 | [watermark] 8 | # 默认开启 9 | enabled = 1 10 | # 起始位置: 左上 0 (默认), 右上 1, 右下 2, 左下 3 11 | start = 0 12 | # 旋转方向: 顺时针 1, 逆时针 0 (默认) 13 | clockwise = 0 14 | # 哪些图片上水印: 默认在Poster和Thumb上添加 15 | poster = 1 16 | thumb = 1 17 | fanart = 0 18 | 19 | -------------------------------------------------------------------------------- /config.py: -------------------------------------------------------------------------------- 1 | import logging 2 | from typing import Dict, Any 3 | from mbot.core.plugins import ( 4 | plugin, 5 | ) 6 | 7 | _LOGGER = logging.getLogger(__name__) 8 | 9 | proxies = { 10 | "http": "", 11 | "https": "", 12 | } 13 | 14 | watch_folder = [] 15 | 16 | target_folder = "" 17 | 18 | link_mode = "0" 19 | 20 | 21 | def init_config(web_config: dict[str, str]): 22 | global watch_folder, target_folder, proxies, link_mode 23 | 24 | to_watch = web_config.get("watch_folder") 25 | if to_watch: 26 | watch_folder = [folder.split(":") for folder in to_watch.split(",")] 27 | logging.info("MDC插件已启用, 监视文件夹: %s" % watch_folder) 28 | 29 | target_folder = web_config.get("target_folder") or "" 30 | 31 | proxy = web_config.get("proxy") or "" 32 | proxies["http"] = proxy 33 | proxies["https"] = proxy 34 | 35 | link_mode = web_config.get("link_mode") or "0" 36 | 37 | 38 | @plugin.config_changed 39 | def config_changed(config: Dict[str, Any]): 40 | init_config(config) 41 | -------------------------------------------------------------------------------- /event.py: -------------------------------------------------------------------------------- 1 | import os 2 | import logging 3 | from mbot.core.event.models import EventType 4 | from mbot.core.plugins import plugin 5 | from mbot.core.plugins import PluginContext 6 | from typing import Dict 7 | 8 | from . import config 9 | from .command import mdc_dir 10 | 11 | _LOGGER = logging.getLogger(__name__) 12 | 13 | 14 | # { 15 | # 'name': '三体.ThreeBody.S01.2023.2160p.V2.WEB-DL.H265.AAC-HHWEB', 16 | # 'hash': '96773744314c9a487462a86b9d04dbb90ca7ce14', 17 | # 'save_path': '/nas/downloads/tv/', 18 | # 'content_path': '/nas/downloads/tv/三体.ThreeBody.S01.2023.2160p.V2.WEB-DL.H265.AAC-HHWEB/ThreeBody.S01E16.2023.2160p.V2.WEB-DL.H265.AAC-HHWEB.mp4', 19 | # 'progress': 100, 20 | # 'size': 1081936959, 21 | # 'size_str': '1.01 GB', 22 | # 'dlspeed': 0, 23 | # 'dlspeed_str': '0', 24 | # 'upspeed': 0, 25 | # 'upspeed_str': '0', 26 | # 'uploaded': 3172779138, 27 | # 'uploaded_str': '2.95 GB', 28 | # 'seeding_time': 7512, 29 | # 'downloaded': 1092912248, 30 | # 'downloaded_str': '1.02 GB', 31 | # 'ratio': 2.903050216342712, 32 | # } 33 | @plugin.on_event(bind_event=[EventType.DownloadCompleted], order=1) 34 | def on_event(ctx: PluginContext, event_type: str, data: Dict): 35 | """ 36 | 触发绑定的事件后调用此函数 37 | 函数接收参数固定。第一个为插件上下文信息,第二个事件类型,第三个事件携带的数据 38 | """ 39 | 40 | save_path = data.get("source_path") 41 | _LOGGER.info("[MDC事件] source_path: %s " % save_path) 42 | if not save_path: 43 | return 44 | 45 | _LOGGER.info("[MDC事件] watch_folder: %s " % config.watch_folder) 46 | flag = False 47 | target_folder = None 48 | # 检查是否匹配监控目录配置 49 | for folders in config.watch_folder: 50 | dir = folders[0] 51 | if save_path.startswith(dir): 52 | flag = True 53 | if len(folders) > 1: 54 | target_folder = folders[1] 55 | break 56 | if not flag: 57 | return 58 | 59 | _LOGGER.info("[MDC事件] 下载地址与监控目录匹配: %s, 开始执行刮削" % save_path) 60 | 61 | mdc_dir(save_path, target_folder) 62 | -------------------------------------------------------------------------------- /logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdc-ng/mdc_mbot_plugin/23488545fd70ea75885edeb8337abdec094d8a41/logo.png -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mdc_mbot_plugin", 3 | "title": "MDC插件", 4 | "author": "aj", 5 | "description": "MDC基础库", 6 | "_comment_start": "x-release-please-start-version", 7 | "version": "1.8.0", 8 | "_comment_end": "x-release-please-end", 9 | "requirements": [], 10 | "dependencies": { 11 | "appVersion": ">=1.9.25" 12 | }, 13 | "logoUrl": "/plugins/mdc_mbot_plugin/logo.png", 14 | "githubUrl": "https://github.com/mdc-ng/mdc_mbot_plugin", 15 | "helpDocUrl": "https://github.com/mdc-ng/mdc_mbot_plugin", 16 | "configField": [ 17 | { 18 | "fieldName": "proxy", 19 | "fieldType": "String", 20 | "label": "代理设置", 21 | "defaultValue": "" 22 | }, 23 | { 24 | "fieldName": "watch_folder", 25 | "fieldType": "String", 26 | "label": "监控路径,英文逗号分隔. 在每个监控路径后可以用英文冒号(:)附加一个该路径对应的目标路径", 27 | "defaultValue": "" 28 | }, 29 | { 30 | "fieldName": "target_folder", 31 | "fieldType": "String", 32 | "label": "默认刮削整理目标路径", 33 | "defaultValue": "" 34 | }, 35 | { 36 | "fieldName": "link_mode", 37 | "fieldType": "String", 38 | "label": "整理模式, 0:硬链接, 1:复制", 39 | "defaultValue": "0" 40 | } 41 | ] 42 | } 43 | --------------------------------------------------------------------------------