diff --git a/docs/social-media.md b/docs/social-media.md index 06ea9e7cd..254ceb9d5 100644 --- a/docs/social-media.md +++ b/docs/social-media.md @@ -302,6 +302,10 @@ Tiny Tiny RSS 会给所有 iframe 元素添加 `sandbox="allow-scripts"` 属性 +### bilibili 热搜 + + + ### 排行榜 diff --git a/lib/v2/bilibili/hotSearch.js b/lib/v2/bilibili/hotSearch.js new file mode 100644 index 000000000..6dc279f1e --- /dev/null +++ b/lib/v2/bilibili/hotSearch.js @@ -0,0 +1,25 @@ +const got = require('@/utils/got'); + +module.exports = async (ctx) => { + const url = `https://api.bilibili.com/x/web-interface/wbi/search/square?limit=10&platform=web&wts=${Math.floor(Date.now() / 1000)}`; + const response = await got({ + method: 'get', + url, + headers: { + Referer: `https://api.bilibili.com`, + }, + }); + const trending = response?.data?.data?.trending; + const title = trending?.title; + const list = trending?.list || []; + ctx.state.data = { + title, + link: url, + description: 'bilibili热搜', + item: list.map((item) => ({ + title: item.keyword, + description: `${item.keyword}
${item.icon ? `` : ''}`, + link: item.link || item.goto || `https://search.bilibili.com/all?${new URLSearchParams({ keyword: item.keyword })}&from_source=webtop_search`, + })), + }; +}; diff --git a/lib/v2/bilibili/maintainer.js b/lib/v2/bilibili/maintainer.js index 45418145d..3560edd90 100644 --- a/lib/v2/bilibili/maintainer.js +++ b/lib/v2/bilibili/maintainer.js @@ -8,6 +8,7 @@ module.exports = { '/followings/article/:uid': ['woshiluo'], '/followings/dynamic/:uid/:disableEmbed?': ['TigerCubDen'], '/followings/video/:uid/:disableEmbed?': ['LogicJake'], + '/hot-search': ['CaoMeiYouRen'], '/link/news/:product': ['Qixingchen'], '/live/area/:areaID/:order': ['Qixingchen'], '/live/room/:roomID': ['Qixingchen'], diff --git a/lib/v2/bilibili/radar.js b/lib/v2/bilibili/radar.js index 15508bf86..911dd47b3 100644 --- a/lib/v2/bilibili/radar.js +++ b/lib/v2/bilibili/radar.js @@ -34,6 +34,12 @@ module.exports = { source: '/video/online.html', target: '/bilibili/online', }, + { + title: 'bilibili热搜', + docs: 'https://docs.rsshub.app/social-media.html#bilibili', + source: '/', + target: '/bilibili/hot-search', + }, ], space: [ { diff --git a/lib/v2/bilibili/router.js b/lib/v2/bilibili/router.js index 976cc36b8..0257e8587 100644 --- a/lib/v2/bilibili/router.js +++ b/lib/v2/bilibili/router.js @@ -9,6 +9,7 @@ module.exports = (router) => { router.get('/followings/dynamic/:uid/:disableEmbed?', require('./followings_dynamic')); router.get('/followings/video/:uid/:disableEmbed?', require('./followings_video')); router.get('/link/news/:product', require('./linkNews')); + router.get('/hot-search', require('./hotSearch')); router.get('/live/area/:areaID/:order', require('./liveArea')); router.get('/live/room/:roomID', require('./liveRoom')); router.get('/live/search/:key/:order', require('./liveSearch')); diff --git a/lib/v2/oncc/money18.js b/lib/v2/oncc/money18.js index bd1137736..9edea9a04 100644 --- a/lib/v2/oncc/money18.js +++ b/lib/v2/oncc/money18.js @@ -48,7 +48,11 @@ module.exports = async (ctx) => { } catch (e) { if (e.code === 'ERR_NON_2XX_3XX_RESPONSE') { hasArticle = false; - apiUrl = toApiUrl(dayjs().subtract(++i, 'day').format('YYYYMMDD')); + apiUrl = toApiUrl( + dayjs() + .subtract(++i, 'day') + .format('YYYYMMDD') + ); } } }