fix: PAR注入ctx对象(httpClient+siteUrl+auth)对齐mediabo的httpGet模式

This commit is contained in:
mediabot-pt
2026-07-01 22:58:48 +08:00
parent 2c220cd829
commit 641297b549

View File

@@ -84,7 +84,13 @@ public class GroovyScriptEngine {
binding.setVariable("json", objectMapper);
binding.setVariable("utils", new ScriptUtils());
binding.setVariable("http", new HttpHelper(httpClient));
if (siteCtx != null) binding.setVariable("_ctx", siteCtx);
// 提供 ctx 对象,使 httpGet(ctx, path) 在 PAR 和 mediabo 中用法一致
Map<String, Object> ctx = new HashMap<>();
ctx.put("httpClient", httpClient);
if (siteCtx != null) {
ctx.putAll(siteCtx); // siteUrl, auth
}
binding.setVariable("ctx", ctx);
GroovyShell shell = new GroovyShell(classLoader, binding);
String fullScript = SCRIPT_PREFIX + groovyScript + "\n// PAR 调用入口\nreturn parse(content, url)";