Skip to content

anx-rule/2 格式 ​

最小结构 ​

json
{
  "format": "anx-rule/2",
  "id": "example",
  "name": "Example Anime",
  "baseUrl": "https://api.example.com",
  "iconUrl": "https://example.com/favicon.ico",
  "description": "示例 JSON API 规则",
  "headers": {
    "User-Agent": "Mozilla/5.0 ...",
    "Accept": "application/json"
  },
  "search": [],
  "detail": [],
  "play": []
}

顶层字段 ​

字段类型必需说明
formatstring推荐当前值 anx-rule/2
idstring是稳定、唯一;通常与文件名和索引 key 一致
namestring是用户可见名称
baseUrlURL是URL 解析与相对请求的基准
iconUrlHTTP(S) URL推荐规则库和源管理页图标
descriptionstring否简短用途说明
headersobject否规则的全局请求头
recipesstring[]否maccms、player_aaaa
searchstep[]是搜索管线
detailstep[]是详情/剧集管线
playstep[]是播放解析管线
useWebviewboolean否允许 sniff 使用 WebView
directConnectionboolean否绕过系统代理;仅在站点确有同出口绑定时使用

enabled、createdAt、updatedAt 属于安装后的本地生命周期字段,贡献仓库规则时通常无需手工填写。

完整 JSON API 示例 ​

json
{
  "format": "anx-rule/2",
  "id": "example",
  "name": "Example Anime",
  "baseUrl": "https://api.example.com",
  "iconUrl": "https://example.com/favicon.ico",
  "headers": {
    "Accept": "application/json",
    "Origin": "https://example.com",
    "Referer": "https://example.com/"
  },
  "search": [
    {
      "op": "fetch",
      "url": "/api/videos?keyword={keyword}"
    },
    {
      "op": "jsonSeries",
      "listPath": "data.records",
      "idKey": "id",
      "nameKey": "title",
      "imageKey": "cover",
      "descKey": "summary",
      "detailUrlTemplate": "/api/videos/{id}"
    }
  ],
  "detail": [
    { "op": "follow" },
    {
      "op": "jsonEpisodes",
      "episodesPath": "data.episodes",
      "episodeNameKey": "label",
      "episodeIdTemplate": "{episodeId:raw}",
      "sourceName": "默认线路"
    }
  ],
  "play": [
    {
      "op": "fetch",
      "url": "/api/episodes/{episodeId:raw}/play"
    },
    {
      "op": "setMediaHeaders",
      "headers": {
        "Referer": "https://example.com/"
      }
    },
    {
      "op": "json",
      "path": "data.playUrl"
    }
  ]
}

模板变量 ​

字符串参数支持 {name} 与 {name:raw}:

  • {name}:URL 编码后插入。
  • {name:raw}:原样插入。

内置变量:

变量可用阶段含义
keywordsearch搜索关键词
seriesIddetail搜索产出的系列标识或详情 URL
episodeIdplay详情产出的剧集标识
baseUrl全部规则基准 URL
timestamp全部当前时间戳
url全部当前值的字符串形式

setVar 可以创建自定义变量。JSON 列表操作符还会把当前条目字段作为模板变量提供。

结果契约 ​

Series ​

搜索结果至少包含稳定的 seriesId 与 name,可附带图片、简介、BGM subject id 和评分。

Source / Episode ​

详情结果是一组线路。每条 Source 包含线路名和 Episode 列表;每集至少有 episodeId、顺序索引与显示名。

播放结果 ​

播放 URL 不能为空,并应在 URL 归一化后仍为真实媒体或播放器支持的 Magnet/Torrent 标识。若媒体需要 Referer、User-Agent、Cookie 或其他头部,必须在管线中明确声明。

文档内容采用项目许可证约束;第三方站点与内容不由 AniBaka 提供。