docs: API.md更新脚本接口为推荐无版本号方式+默认模板回退
This commit is contained in:
46
docs/API.md
46
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 新增字段
|
||||
|
||||
Reference in New Issue
Block a user