Files
Auto_Bangumi/docs/ja/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
3.0 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# サンプルプラグイン
サンプルはリポジトリの [`examples/plugins/`](https://github.com/EstrellaXD/Auto_Bangumi/tree/main/examples/plugins) にあります。Docker イメージには含まれません。各サンプルに README とテストがあり、CI が 1 つずつ実行します。
| サンプル | 内容 |
| --- | --- |
| `webhook-on-event` | `@subscribe("*")`、設定フォーム、`secret_field`。選んだイベントを URL に POST します。HMAC 署名は任意です |
| `custom-rss-site` | `search_site` Provider と `http.request` フック。プライベートサイトのリクエストに Cookie を付けます。`SearchSiteContract` |
| `template-rename` | `rename_strategy` Provider。独自フィルター付きのファイル名テンプレート。`RenameSkipped`。`RenameStrategyContract` |
| `nfo-writer` | `torrent.organized` を購読し、本編の隣に `.nfo` を書きます。パス変換。冪等 |
| `ntfy-notifier` | `notifier` Provider。バックエンドが拒否したときは `False` を返します。`NotifierContract` |
| `run-command` | `torrent.organized` / `file.renamed` を購読し、外部コマンドを実行します。引数リストはシェルを通しません。環境変数とプレースホルダー。タイムアウトで終了 |
| `strm-writer` | `torrent.organized` を購読し、メディアのフォルダー構成どおりに `.strm` を書きます。冪等 |
| `synology-chat-notifier` | `notifier` Provider。フォームフィールド `payload=<JSON>` を送ります。HTTP 200 でも `success: false` なら `False` を返します |
| `slack-notifier` | `notifier` Provider。mrkdwn をエスケープします。ポスターがあるときは画像ブロックを付けます |
| `manual-pick` | フロントエンドスロット `bangumi.detail.tab`、プラグインのルート、プラグイン KV、イベント |
## サンプルをインストールする
```bash
cp -r examples/plugins/ntfy-notifier config/plugins/local/
```
設定 → プラグインで「未署名プラグインを許可」をオンにし、プラグインを有効にします。
## サンプルのテストを実行する
リポジトリのルートで実行します。スクリプトは各サンプルのマニフェストを検証し、そのテストを実行します(CI と同じ)。
```bash
scripts/test_example_plugins.sh
```
スクリプトは `backend/` の環境で動き、そこには SDK が編集可能モードでインストールされています。サンプルの `pyproject.toml` は `autobangumi-sdk` に依存しますが、このパッケージは PyPI にありません。サンプルをリポジトリの外にコピーして単独でテストする場合は、先にサンプルのディレクトリで `uv add <wheel のパス>` を実行してから `uv run pytest` を実行します。
Jellyfin / Emby / Plex のライブラリ更新にプラグインを書く必要はありません。組み込みプラグイン `media-server-refresh` が対応しています。