From 5723536ef744d24d3038ead7af628eb9b861f6f6 Mon Sep 17 00:00:00 2001 From: mediabot-pt <295750538+mediabot-pt@users.noreply.github.com> Date: Wed, 1 Jul 2026 16:23:01 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20API.md=E6=9B=B4=E6=96=B0=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=E6=8E=A5=E5=8F=A3=E4=B8=BA=E6=8E=A8=E8=8D=90=E6=97=A0?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=8F=B7=E6=96=B9=E5=BC=8F+=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E6=A8=A1=E6=9D=BF=E5=9B=9E=E9=80=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/API.md | 46 +++++++++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/docs/API.md b/docs/API.md index 73da596..8ec4050 100644 --- a/docs/API.md +++ b/docs/API.md @@ -145,6 +145,7 @@ curl -H "If-None-Match: a1b2c3d4..." http://par:9012/api/v1/manifest "siteType": "private", "schemaVersion": "1.0.0", "status": "active", + "siteType": "nexusphp", "latestVersion": "1.2.0", "configHash": "a1b2c3d4...", "hasScript": false, @@ -259,16 +260,29 @@ curl -H "If-None-Match: a1b2c3d4..." http://par:9012/api/v1/manifest | 方法 | 路径 | 认证 | 说明 | |------|------|------|------| -| GET | `/api/v1/configs/{siteId}/{version}/script` | 无 | 下载 Groovy 脚本 | +| GET | `/api/v1/configs/{siteId}/script` | 无 | 下载最新脚本(推荐) | +| GET | `/api/v1/configs/{siteId}/{version}/script` | 无 | 下载指定版本脚本 | + +#### GET /api/v1/configs/{siteId}/script + +**推荐使用**。不需要指定版本号,自动返回该站点可用的最新脚本。 + +优先级:自定义脚本 > 站点类型默认模板 > 404 + +```bash +# 下载 hdfans 脚本 +curl http://par:9012/api/v1/configs/hdfans/script + +# 有自定义脚本 → 返回自定义 Groovy +# 无自定义脚本 → 按 siteType 返回默认模板(如 nexusphp 类型) +# siteType 未知 → 404 +``` + +返回 `Content-Type: text/plain;charset=UTF-8`。 #### GET /api/v1/configs/{siteId}/{version}/script -返回 `Content-Type: text/plain;charset=UTF-8`,原始 Groovy 脚本内容。 - -```bash -# 下载 mteam v1 的 Groovy 脚本 -curl http://par:9012/api/v1/configs/mteam/1/script -``` +指定版本下载(仅返回该版本的自定义脚本,不回退默认模板)。 #### 集成流程 @@ -276,16 +290,18 @@ curl http://par:9012/api/v1/configs/mteam/1/script mediabot 启动 │ ▼ -GET /api/v1/manifest ← 获取站点列表 - │ { "siteId":"mteam","latestVersion":"1","hasScript":true } +GET /api/v1/manifest + │ { "siteId":"hdfans","siteType":"nexusphp","hasScript":false,... } + │ { "siteId":"mteam","siteType":"mtorrent","hasScript":true,... } │ - ├─ hasScript == true - │ └─ GET /api/v1/configs/{siteId}/{latestVersion}/script ← 下载 Groovy 脚本 - │ → 编译并执行 parse/sync/search/sign 方法 + ▼ +GET /api/v1/configs/{siteId}/script ← 不传版本号,自动选最优 │ - └─ hasScript == false - └─ GET /api/v1/configs/{siteId}/{latestVersion} ← 下载 JSON 配置 - → 按 JSON 配置中的选择器规则执行 + ├─ 自定义脚本存在 → 返回自定义 Groovy + └─ 无自定义 → 按 siteType 返回默认模板(nexusphp/gazelle/unit3d/mtorrent) + │ + ▼ +编译 Groovy 脚本 → 调用 sync(ctx) / search(ctx,params) / sign(ctx) ``` #### Manifest 新增字段