From 3ff64825483aa8f83ea9f8282e8a76ccefc41300 Mon Sep 17 00:00:00 2001
From: CaoMeiYouRen <40430746+CaoMeiYouRen@users.noreply.github.com>
Date: Mon, 27 Feb 2023 19:47:26 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=20bilibili=20?=
=?UTF-8?q?=E7=83=AD=E6=90=9C=20(#11958)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* feat(route): 添加 百度股市通
* fix: 修改 百度股市通 路径
* docs: 添加 百度股市通 文档
* feat: 添加 radar 支持
* fix: 按字母顺序插入新路由
* feat(route): 新增 腾讯新闻 - 新型冠状病毒肺炎疫情实时追踪
* fix: 优化 腾讯新闻 - 新型冠状病毒肺炎疫情实时追踪 的标题
* fix: 修复 腾讯新闻 - 新型冠状病毒肺炎疫情实时追踪 部分情况下的非空判断
* fix: 修复 地区名称标题的问题
* fix: 腾讯新闻 - 新型冠状病毒肺炎疫情实时追踪 的 guid 增加 pubDate
* fix: 修复 腾讯新闻 - 新型冠状病毒肺炎疫情实时追踪 guid 中添加 pubDate
* fix: 修改 腾讯新闻 - 新型冠状病毒肺炎疫情实时追踪 的 title
* feat(route): 修复 HelloGitHub 的 月刊 路由
* fix: remove guid
* feat(route): 新增 bilibili 热搜
* feat(route): 完善 bilibili热搜 的 radar
* fix: 优化 bilibili热搜 list 的非空判断
---
docs/social-media.md | 4 ++++
lib/v2/bilibili/hotSearch.js | 25 +++++++++++++++++++++++++
lib/v2/bilibili/maintainer.js | 1 +
lib/v2/bilibili/radar.js | 6 ++++++
lib/v2/bilibili/router.js | 1 +
lib/v2/oncc/money18.js | 6 +++++-
6 files changed, 42 insertions(+), 1 deletion(-)
create mode 100644 lib/v2/bilibili/hotSearch.js
diff --git a/docs/social-media.md b/docs/social-media.md
index 06ea9e7cd345fc..254ceb9d500d9d 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 00000000000000..6dc279f1ee9e6d
--- /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 45418145d2d4e3..3560edd9063378 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 15508bf8629d26..911dd47b32637e 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 976cc36b82dda3..0257e8587fb227 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 bd113773601f43..9edea9a04bdf75 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')
+ );
}
}
}