From 3813afad84eadc55b4153757455314aa60d1501e Mon Sep 17 00:00:00 2001 From: Weirdo <59109940+Hermes1030@users.noreply.github.com> Date: Sun, 28 Dec 2025 23:35:16 +0800 Subject: [PATCH] =?UTF-8?q?feat(route):=20=E6=B7=BB=E5=8A=A0BTBTLA?= =?UTF-8?q?=E6=8C=87=E5=AE=9A=E5=89=A7=E5=90=8D=E8=AF=A6=E6=83=85=E8=B7=AF?= =?UTF-8?q?=E7=94=B1=20(#20766)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(route): 添加BT影视更新列表路由 * 更新 gxlist.ts * feat(route): 添加BTBTLA指定剧名详情路由 - 新增 /detail/:name 路由用于获取指定电影或电视剧的详细信息 - 实现通过剧名搜索获取ID并解析详情页内容的功能 - 添加磁力链接获取功能,使用缓存优化性能 - 更新命名空间描述,完善URL格式 - 优化最近更新页面标题显示格式 * fix(route): 修正 btbtla 详情页路由示例 - 修复了路由示例路径缺少 btbtla 前缀的问题 - 确保示例路径与实际路由配置保持一致 * refactor(btbtla): 优化详情页路由和磁力链接处理 - 使用路由参数替代路径解析获取名称 - 导入配置模块以使用缓存过期设置 - 优化磁力链接获取逻辑并添加缓存 - 改进链接和磁力链接的返回值处理 - 添加种子文件下载支持和类型标识 - 简化空值检查逻辑 * 更新 detail.ts Co-authored-by: Tony * 更新 detail.ts Co-authored-by: Tony --------- Co-authored-by: pull[bot] <39814207+pull[bot]@users.noreply.github.com> --- lib/routes/btbtla/detail.ts | 94 ++++++++++++++++++++++++++++++++++ lib/routes/btbtla/gxlist.ts | 4 +- lib/routes/btbtla/namespace.ts | 4 +- 3 files changed, 98 insertions(+), 4 deletions(-) create mode 100644 lib/routes/btbtla/detail.ts diff --git a/lib/routes/btbtla/detail.ts b/lib/routes/btbtla/detail.ts new file mode 100644 index 000000000..fd9ca46bb --- /dev/null +++ b/lib/routes/btbtla/detail.ts @@ -0,0 +1,94 @@ +import { load } from 'cheerio'; // 类似 jQuery 的 API HTML 解析器 + +import type { Route } from '@/types'; +import cache from '@/utils/cache'; +import ofetch from '@/utils/ofetch'; // 统一使用的请求库 + +export const route: Route = { + path: '/detail/:name', + categories: ['multimedia'], + example: '/btbtla/detail/雍正王朝', + parameters: { name: '电影 | 电视剧名称' }, + features: { + requireConfig: false, + requirePuppeteer: false, + antiCrawler: false, + supportBT: true, + supportPodcast: false, + supportScihub: false, + }, + name: 'BTBTLA | 指定剧名', + maintainers: ['Hermes1030'], + handler, +}; + +async function handler(ctx) { + const name = ctx.req.param('name'); + + const idUrl = await getId(name); + if (!idUrl) { + return null; + } + const detailLink = 'https://www.btbtla.com' + idUrl; + const detailResponse = await ofetch(detailLink); + const $ = load(detailResponse); + + const itemElements = $('div[name=download-list] .module-downlist.selected .module-row-one.active .module-row-info').toArray(); + + // 使用缓存处理所有项目 + const items = await Promise.all( + itemElements.map(async (element) => { + const $row = $(element); + const title = $row.find('.module-row-title h4').text().trim(); + const link = $row.find('.module-row-text').attr('href'); + + // 使用缓存获取磁力链接 + const magnet = await cache.tryGet( + `btbtla:magnet:${link}`, + async () => { + if (link) { + return await getMagnet('https://www.btbtla.com' + link); + } + return ''; + }, + ); + + return { + title, + link, + enclosure_url: magnet, + enclosure_type: 'application/x-bittorrent', + }; + }) + ); + + const moduleTitle = 'BTBTLA | ' + $('.page-title').text(); + + return { + title: moduleTitle, + link: detailLink, + description: moduleTitle, + item: items, + }; +} + +async function getId(name: string) { + const searchLink = 'https://www.btbtla.com/search/'; + const response = await ofetch(searchLink + name); + const $ = load(response); + const link = $(`.module-items .module-item-titlebox a[title="${name}"]`).attr('href'); + + // format '/detail/46830832.html' + return link; +} + +async function getMagnet(link: string | undefined) { + if (!link) { + return null; + } + const response = await ofetch(link); + const $ = load(response); + const magnet = $('.btn-important').attr('href'); + + return magnet; +} diff --git a/lib/routes/btbtla/gxlist.ts b/lib/routes/btbtla/gxlist.ts index 698d1a71a..455195b17 100644 --- a/lib/routes/btbtla/gxlist.ts +++ b/lib/routes/btbtla/gxlist.ts @@ -8,7 +8,7 @@ export const route: Route = { example: '/btbtla/gxlist', handler, maintainers: ['Hermes1030'], - name: 'BTBTLA', + name: 'BTBTLA | 最近更新', path: '/gxlist', url: 'btbtla.com/tt/gxlist.html', }; @@ -35,7 +35,7 @@ async function handler() { }; }); - const moduleTitle = $('.module-title').text(); + const moduleTitle = 'BTBTLA | ' + $('.module-title').text(); return { title: moduleTitle, diff --git a/lib/routes/btbtla/namespace.ts b/lib/routes/btbtla/namespace.ts index 217812113..c8492a529 100644 --- a/lib/routes/btbtla/namespace.ts +++ b/lib/routes/btbtla/namespace.ts @@ -2,6 +2,6 @@ import type { Namespace } from '@/types'; export const namespace: Namespace = { name: 'BT影视', - url: 'btbtla.com', - description: 'BT影视更新列表', + url: 'www.btbtla.com', + description: 'BT影视的页面内容,最近更新列表,视频种子列表。', };