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] }