Files
Auto_Bangumi/docs/en/dev/plugins/examples.md
Estrella Pan 8312f47769 feat(plugins): 新增 run-command、strm-writer、synology-chat-notifier、slack-notifier 示例插件
- run-command:torrent.organized / file.renamed 后运行外部命令,参数列表直接 exec,
  事件字段以 AB_* 环境变量与 {占位符} 传入,超时终止(#897、#668)
- strm-writer:按媒体目录结构写 .strm,内容为地址前缀加相对路径(#428)
- synology-chat-notifier:Synology Chat 传入 Webhook,payload= 表单 JSON(#887)
- slack-notifier:Slack Incoming Webhook,带海报时附图片块(#277)
2026-10-21 09:08:56 +02:00

37 lines
2.4 KiB
Markdown

# Example Plugins
The examples are in [`examples/plugins/`](https://github.com/EstrellaXD/Auto_Bangumi/tree/main/examples/plugins) of the repository. They are not in the Docker image. Each example has its own README and tests. CI runs them one by one.
| Example | What it shows |
| --- | --- |
| `webhook-on-event` | `@subscribe("*")`, a config form, `secret_field`. Sends selected events as a POST to a URL, with an optional HMAC signature |
| `custom-rss-site` | A `search_site` Provider and an `http.request` hook. Adds a Cookie to the requests of a private site. `SearchSiteContract` |
| `template-rename` | A `rename_strategy` Provider with a file-name template that has its own filters. `RenameSkipped`. `RenameStrategyContract` |
| `nfo-writer` | Subscribes to `torrent.organized` and writes an `.nfo` next to each media file. Path mapping. Idempotent |
| `ntfy-notifier` | A `notifier` Provider. Returns `False` when the backend refuses. `NotifierContract` |
| `run-command` | Subscribes to `torrent.organized` / `file.renamed` and runs an external command. The argument list does not go through a shell. Environment variables and placeholders. Kill on timeout |
| `strm-writer` | Subscribes to `torrent.organized` and writes `.strm` files that mirror the media folders. Idempotent |
| `synology-chat-notifier` | A `notifier` Provider. Sends the form field `payload=<JSON>`. Returns `False` on HTTP 200 with `success: false` |
| `slack-notifier` | A `notifier` Provider. Escapes mrkdwn. Adds an image block when a poster is available |
| `manual-pick` | The frontend slot `bangumi.detail.tab`, plugin routes, plugin KV, events |
## Install an example
```bash
cp -r examples/plugins/ntfy-notifier config/plugins/local/
```
Turn on "Allow unsigned plugins" in Settings → Plugins, then enable the plugin.
## Run the tests of an example
Run the script in the repository root. It validates the manifest of each example and runs its tests, the same as CI:
```bash
scripts/test_example_plugins.sh
```
The script runs in the `backend/` environment, which has an editable install of the SDK. The `pyproject.toml` of each example needs `autobangumi-sdk`, and this package is not on PyPI. To test an example outside the repository, first run `uv add <path to the wheel>` in the example directory. Then run `uv run pytest`.
You do not need a plugin to refresh a Jellyfin, Emby or Plex library. The built-in plugin `media-server-refresh` does it.