fix(route/bangumi): update follow rank parsing logic (#17050)

* fix(bangumi): update follow rank parsing logic

* fix(bangumi): update follow rank parsing logic

* fix(route/bangumi): update follow rank parsing logic
This commit is contained in:
Neko Aria
2024-10-09 22:23:15 +08:00
committed by GitHub
parent 2bdc5cd97b
commit b20f9f70dc
+19 -22
View File
@@ -7,7 +7,7 @@ export const route: Route = {
path: '/:type/followrank',
categories: ['anime'],
example: '/bangumi/anime/followrank',
parameters: { type: '类型:anime - 动画, book - 图书, music - 音乐, game - 游戏, real - 三次元' },
parameters: { type: '类型:anime - 动画,book - 图书,music - 音乐,game - 游戏,real - 三次元' },
features: {
requireConfig: false,
requirePuppeteer: false,
@@ -23,7 +23,7 @@ export const route: Route = {
},
],
name: '成员关注榜',
maintainers: ['honue', 'zhoukuncheng'],
maintainers: ['honue', 'zhoukuncheng', 'NekoAria'],
handler,
};
@@ -42,25 +42,22 @@ async function handler(ctx) {
const $ = load(response);
const items = [
...$('#columnB > div:nth-child(4) > table > tbody')
.find('tr')
.toArray()
.map((item) => {
const aTag = $(item).children('td').next().find('a');
return {
title: aTag.html(),
link: 'https://bgm.tv' + aTag.attr('href'),
};
}),
...$('#chl_subitem > ul')
.find('li')
.toArray()
.map((item) => ({
title: $(item).children('a').attr('title'),
link: 'https://bgm.tv' + $(item).children('a').attr('href'),
})),
];
const items = $('.featuredItems .mainItem')
.map((_, item) => {
const $item = $(item);
const link = 'https://bgm.tv' + $item.find('a').first().attr('href');
const imageUrl = $item
.find('.image')
.attr('style')
?.match(/url\((.*?)\)/)?.[1];
const info = $item.find('small.grey').text();
return {
title: $item.find('.title').text().trim(),
link,
description: `<img src="${imageUrl}"><br>${info}`,
};
})
.toArray();
const RANK_TYPES = {
tv: '动画',
@@ -75,6 +72,6 @@ async function handler(ctx) {
title: `BangumiTV 成员关注${RANK_TYPES[type]}榜`,
link: url,
item: items,
description: `BangumiTV 首页-成员关注${RANK_TYPES[type]}榜`,
description: `BangumiTV 首页 - 成员关注${RANK_TYPES[type]}榜`,
};
}