Skip to content

Commit

Permalink
fix(route/bangumi): update follow rank parsing logic (#17050)
Browse files Browse the repository at this point in the history
* fix(bangumi): update follow rank parsing logic

* fix(bangumi): update follow rank parsing logic

* fix(route/bangumi): update follow rank parsing logic
  • Loading branch information
NekoAria authored Oct 9, 2024
1 parent 2bdc5cd commit b20f9f7
Showing 1 changed file with 19 additions and 22 deletions.
41 changes: 19 additions & 22 deletions lib/routes/bangumi/tv/other/followrank.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -23,7 +23,7 @@ export const route: Route = {
},
],
name: '成员关注榜',
maintainers: ['honue', 'zhoukuncheng'],
maintainers: ['honue', 'zhoukuncheng', 'NekoAria'],
handler,
};

Expand All @@ -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: '动画',
Expand All @@ -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]}榜`,
};
}

0 comments on commit b20f9f7

Please sign in to comment.