From 92070390463fd7633975fe6b81a903dace78ab34 Mon Sep 17 00:00:00 2001 From: mediabot-pt <295750538+mediabot-pt@users.noreply.github.com> Date: Mon, 6 Jul 2026 10:04:26 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20parseMetadata=E5=A4=8D=E7=94=A8pars?= =?UTF-8?q?eDetailPage=E7=BB=9F=E4=B8=80=E8=A7=A3=E6=9E=90=EF=BC=8C?= =?UTF-8?q?=E6=B6=88=E9=99=A4=E9=87=8D=E5=A4=8D=E7=9A=84=E8=B1=86=E7=93=A3?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=E6=8F=90=E5=8F=96=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/nexusphp-default.groovy | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/docs/nexusphp-default.groovy b/docs/nexusphp-default.groovy index 3c4331e..94033e1 100644 --- a/docs/nexusphp-default.groovy +++ b/docs/nexusphp-default.groovy @@ -35,24 +35,14 @@ Map parseMetadata(context) { def searchItems = parseSearchPage(Jsoup.parse(searchResp.content)).items if (!searchItems || searchItems.isEmpty()) return [matched: false, message: '未搜到'] - // 2. 取第一个结果 → 访问详情 + // 2. 取第一个结果 → 访问详情(复用 parseDetailPage 统一解析) def first = searchItems[0] def detailResp = context.fetch("detail", [id: first.detailUrl]) if (detailResp.status != 200) return [matched: false, message: '详情页访问失败'] + def detail = parseDetailPage(Jsoup.parse(detailResp.content)) - // 3. 提取豆瓣链接 - def detailDoc = Jsoup.parse(detailResp.content) - def dbLink = detailDoc.selectFirst('a[href*=movie.douban.com], a[href*=douban.com/subject]')?.attr('href') - // 也尝试种子的描述区域 - if (!dbLink) dbLink = detailDoc.selectFirst('.rowhead:contains(简介) + td a[href*=douban], #kdescr a[href*=douban]')?.attr('href') - if (!dbLink) { - // 从页面文本中正则提取 - def m = detailResp.content =~ /https?:\/\/(?:movie|www)\.douban\.com\/subject\/(\d+)\/?/ - if (m) dbLink = m[0][0] - } - - return dbLink - ? [matched: true, doubanUrl: dbLink, title: first.title, seedTitle: first.title] + return detail.doubanUrl + ? [matched: true, doubanUrl: detail.doubanUrl, title: first.title, seedTitle: first.title] : [matched: false, message: '未找到豆瓣链接', seedTitle: first.title] }