refactor: 去掉httpGet封装,直接用http.get(url,cookie)
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user