From f237dcd08ef593c0c8f7209b2f37a336f091afe7 Mon Sep 17 00:00:00 2001 From: mediabot-pt <295750538+mediabot-pt@users.noreply.github.com> Date: Wed, 1 Jul 2026 23:17:15 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=8E=BB=E6=8E=89httpGet=E5=B0=81?= =?UTF-8?q?=E8=A3=85=EF=BC=8C=E7=9B=B4=E6=8E=A5=E7=94=A8http.get(url,cooki?= =?UTF-8?q?e)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/pttime.groovy | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/docs/pttime.groovy b/docs/pttime.groovy index 7b884a3..6d1d3eb 100644 --- a/docs/pttime.groovy +++ b/docs/pttime.groovy @@ -76,7 +76,8 @@ private Map parseSign(doc) { Map sign(PluginContext ctx) { if (!ctx.auth) return [message: '未配置认证', loginRequired: true] try { - def body = httpGet(ctx, '/attendance.php') + def url = ctx.siteUrl.replaceAll('/+\$', '') + '/attendance.php' + def body = http.get(url, ctx.auth) def matched = body ==~ /.*(签到成功|已签到|重复签到|获得.*魔力值).*/ return [success: matched, message: matched ? '已签到' : '失败'] } catch (e) { return [message: "签到异常: ${e.message}"] } @@ -85,7 +86,8 @@ Map sign(PluginContext ctx) { Map sync(PluginContext ctx) { if (!ctx.auth) return [message: '未配置认证', loginRequired: true] try { - def body = httpGet(ctx, '/index.php') + def url = ctx.siteUrl.replaceAll('/+\$', '') + '/index.php' + def body = http.get(url, ctx.auth) def doc = Jsoup.parse(body) def infoEl = doc.selectFirst('#info_block') if (!infoEl) { ctx.incomplete = true; return [message: '未找到用户信息'] } @@ -111,7 +113,8 @@ List search(PluginContext ctx, Map params) { try { def keyword = params.keyword ?: '' def page = (params.page ?: 0) as int - def body = httpGet(ctx, "/torrents.php?search=${URLEncoder.encode(keyword,'UTF-8')}&page=${page}") + def url = "${ctx.siteUrl.replaceAll('/+\$', '')}/torrents.php?search=${URLEncoder.encode(keyword,'UTF-8')}&page=${page}" + def body = http.get(url, ctx.auth) def doc = Jsoup.parse(body) def rows = [] doc.select('table.torrents tr:has(td.rowfollow):not(:has(.colhead))').each { row -> @@ -131,11 +134,4 @@ List search(PluginContext ctx, Map params) { } catch (e) { return [] } } -// ── HTTP 封装(mediabot用,设置 capturedUrl/Body 以便自动提交到 PAR)── -private String httpGet(PluginContext ctx, String path) { - def url = path.startsWith('http') ? path : ctx.siteUrl.replaceAll('/+\$', '') + '/' + path.replaceAll('^/+', '') - ctx.capturedUrl = url - ctx.capturedBody = http.get(url, ctx.auth) - return ctx.capturedBody -}