feat(route): 添加BTBTLA指定剧名详情路由 (#20766)
* feat(route): 添加BT影视更新列表路由 * 更新 gxlist.ts * feat(route): 添加BTBTLA指定剧名详情路由 - 新增 /detail/:name 路由用于获取指定电影或电视剧的详细信息 - 实现通过剧名搜索获取ID并解析详情页内容的功能 - 添加磁力链接获取功能,使用缓存优化性能 - 更新命名空间描述,完善URL格式 - 优化最近更新页面标题显示格式 * fix(route): 修正 btbtla 详情页路由示例 - 修复了路由示例路径缺少 btbtla 前缀的问题 - 确保示例路径与实际路由配置保持一致 * refactor(btbtla): 优化详情页路由和磁力链接处理 - 使用路由参数替代路径解析获取名称 - 导入配置模块以使用缓存过期设置 - 优化磁力链接获取逻辑并添加缓存 - 改进链接和磁力链接的返回值处理 - 添加种子文件下载支持和类型标识 - 简化空值检查逻辑 * 更新 detail.ts Co-authored-by: Tony <TonyRL@users.noreply.github.com> * 更新 detail.ts Co-authored-by: Tony <TonyRL@users.noreply.github.com> --------- Co-authored-by: pull[bot] <39814207+pull[bot]@users.noreply.github.com>
This commit is contained in:
parent
af886e3f43
commit
3813afad84
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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影视的页面内容,最近更新列表,视频种子列表。',
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue