From 0563d2191f108e68844b76a276a372d53b2fb1db Mon Sep 17 00:00:00 2001 From: mediabot-pt <295750538+mediabot-pt@users.noreply.github.com> Date: Wed, 1 Jul 2026 11:15:12 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E7=A7=BB=E9=99=A4=20verify=20?= =?UTF-8?q?=E5=92=8C=20detectAnnounce=20=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/mteam.groovy | 53 ----------------------------------------------- 1 file changed, 53 deletions(-) diff --git a/docs/mteam.groovy b/docs/mteam.groovy index 2dddc33..db57885 100644 --- a/docs/mteam.groovy +++ b/docs/mteam.groovy @@ -90,22 +90,6 @@ Map sync(PluginContext ctx) { } } -Map verify(PluginContext ctx) { - if (!ctx.site.authorization) return [available: false, reason: "未配置 Token"] - try { - def resp = apiGet(ctx, "/api/member/profile") - if (resp.statusCode() == 200) { - def json = new groovy.json.JsonSlurper().parseText(resp.body()) - return json.message == "SUCCESS" - ? [available: true, reason: "Token 验证通过"] - : [available: false, reason: "Token 无效"] - } - return [available: false, reason: "HTTP ${resp.statusCode()}"] - } catch (e) { - return [available: false, reason: "连接失败: ${e.message}"] - } -} - List search(PluginContext ctx, Map params) { if (!ctx.site.authorization) return [] try { @@ -137,43 +121,6 @@ List search(PluginContext ctx, Map params) { } } -Map detectAnnounce(PluginContext ctx) { - if (!ctx.site.authorization) return [error: "未配置 Token"] - try { - // 搜索任意种子获取 ID - def body = groovy.json.JsonOutput.toJson([keyword: "", pageNumber: 1, pageSize: 1, visible: 1]) - def resp = apiPost(ctx, "/api/torrent/search", body) - def json = new groovy.json.JsonSlurper().parseText(resp.body()) - def item = json?.data?.data?.get(0) - if (!item?.id) return [error: "未找到种子"] - - // 生成下载 Token - def dlBody = groovy.json.JsonOutput.toJson([id: item.id.toString()]) - def dlResp = apiPost(ctx, "/api/torrent/genDlToken", dlBody) - def dlJson = new groovy.json.JsonSlurper().parseText(dlResp.body()) - def token = dlJson?.data - if (!token) return [error: "获取下载 Token 失败"] - - // 下载种子文件 - def torResp = ctx.httpClient.send( - java.net.http.HttpRequest.newBuilder() - .uri(new java.net.URI("${ctx.siteUrl}download/${item.id}/${token}")) - .timeout(java.time.Duration.ofSeconds(30)) - .header("User-Agent", "Mozilla/5.0") - .GET().build(), - java.net.http.HttpResponse.BodyHandlers.ofByteArray()) - - if (torResp.statusCode() != 200 || !torResp.body()) return [error: "种子下载失败"] - def info = com.mediabot.util.Bencode.decode(torResp.body()) - def announce = info?.announce - return announce && announce.toString().startsWith("http") - ? [announceUrl: announce.toString()] - : [error: "解析失败"] - } catch (e) { - return [error: e.message] - } -} - // ==================== 工具方法 ==================== private def apiGet(PluginContext ctx, String path) {