Files
Auto_Bangumi/docs/en/dev/plugins/points/http-request.md
Estrella Pan 3258fcca4b docs(4.0-P7): 插件开发文档拆分为总览加每个扩展点一页,补齐中英日三语
- docs/dev/plugins.md 改为总览与导航,旧内容拆入 docs/dev/plugins/
- 新增核心概念、配置表单、事件、前端挂载点、命令行、签名与分发、内置插件、示例页
- 每个扩展点一页,侧边栏由页面表生成
- 改正旧文档中下载器配置、hardlink path_map 与补链按钮的过时描述
2026-10-08 14:51:00 +02:00

1.1 KiB

HTTP Request (http.request)

A transform hook. Every GET request that AB sends (RSS, torrent files, site pages) passes through it. Use it to add a Cookie or to change the User-Agent for a private site. You can change only the headers. AB ignores changes to url and method.

from dataclasses import replace

from pydantic import BaseModel

from ab_sdk import Plugin, hook, points, secret_field


class Options(BaseModel):
    cookie: str = secret_field(description="Site Cookie")


class PrivateSite(Plugin[Options]):
    config_model = Options

    @hook(points.HTTP_REQUEST)
    def auth(self, request):
        if "pt.example.com" not in request.url:
            return None
        return replace(request, headers={**request.headers, "Cookie": self.config.cookie})
  • The parameter HttpRequest has method, url and headers. Return a changed copy, or None for no change.
  • AB calls this hook for each request. Keep it light. Do not make network requests in it.
  • Store the Cookie with secret_field. The WebUI shows only a mask.

Example: examples/plugins/custom-rss-site.