From 87d3a04dfbc4dbcab91a3208c24b20dc62403e2c Mon Sep 17 00:00:00 2001
From: Fatpandac <1779196284@qq.com>
Date: Sun, 23 Jan 2022 03:57:24 +0800
Subject: [PATCH] =?UTF-8?q?Add(route):=20add=20=E5=BE=8B=E5=8A=A8BlockBeat?=
=?UTF-8?q?s=20(#8858)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
docs/new-media.md | 12 ++++++++
lib/v2/blockbeats/index.js | 50 +++++++++++++++++++++++++++++++++
lib/v2/blockbeats/maintainer.js | 3 ++
lib/v2/blockbeats/radar.js | 19 +++++++++++++
lib/v2/blockbeats/router.js | 3 ++
5 files changed, 87 insertions(+)
create mode 100644 lib/v2/blockbeats/index.js
create mode 100644 lib/v2/blockbeats/maintainer.js
create mode 100644 lib/v2/blockbeats/radar.js
create mode 100644 lib/v2/blockbeats/router.js
diff --git a/docs/new-media.md b/docs/new-media.md
index c9ecc8b7c..5fbedd255 100644
--- a/docs/new-media.md
+++ b/docs/new-media.md
@@ -2154,6 +2154,18 @@ column 为 third 时可选的 category:
+## 律动
+
+### 新闻快讯
+
+
+
+| 快讯 | 新闻 |
+| :---: | :--: |
+| flash | news |
+
+
+
## 論盡媒體 AllAboutMacau Media
### 话题
diff --git a/lib/v2/blockbeats/index.js b/lib/v2/blockbeats/index.js
new file mode 100644
index 000000000..d4466f2e7
--- /dev/null
+++ b/lib/v2/blockbeats/index.js
@@ -0,0 +1,50 @@
+const got = require('@/utils/got');
+const cheerio = require('cheerio');
+const { parseRelativeDate } = require('@/utils/parse-date');
+
+const rootUrl = 'https://www.theblockbeats.info';
+
+const channelMap = {
+ flash: '快讯',
+ news: '新闻',
+};
+
+module.exports = async (ctx) => {
+ const channel = ctx.params.channel ?? 'flash';
+
+ const response = await got.get(rootUrl);
+ const $ = cheerio.load(response.data);
+ const list = $('div.news-item')
+ .map((_, item) => {
+ const title = $(item).find('a').attr('title');
+ const link = rootUrl + $(item).find('a').attr('href');
+ const pubDate = parseRelativeDate($(item).find('div.article-time').text());
+
+ return {
+ title,
+ link,
+ pubDate,
+ };
+ })
+ .filter((_, item) => item.title && item.link.includes(channel))
+ .get();
+
+ const items = await Promise.all(
+ list.map((item) =>
+ ctx.cache.tryGet(item.link, async () => {
+ const detailResponse = await got.get(item.link);
+ const content = cheerio.load(detailResponse.data);
+
+ item.description = content(`div.${channel}-content`).html();
+
+ return item;
+ })
+ )
+ );
+
+ ctx.state.data = {
+ title: `TheBlockBeats - ${channelMap[channel]}`,
+ link: rootUrl,
+ item: items,
+ };
+};
diff --git a/lib/v2/blockbeats/maintainer.js b/lib/v2/blockbeats/maintainer.js
new file mode 100644
index 000000000..27645c3d7
--- /dev/null
+++ b/lib/v2/blockbeats/maintainer.js
@@ -0,0 +1,3 @@
+module.exports = {
+ '/:channel?': ['Fatpandac'],
+};
diff --git a/lib/v2/blockbeats/radar.js b/lib/v2/blockbeats/radar.js
new file mode 100644
index 000000000..fff37fce8
--- /dev/null
+++ b/lib/v2/blockbeats/radar.js
@@ -0,0 +1,19 @@
+module.exports = {
+ 'theblockbeats.info': {
+ _name: '律动',
+ rszhaopin: [
+ {
+ title: '快讯',
+ docs: 'https://docs.rsshub.app/new-media.html#lu-dong-xin-wen-kuai-xun',
+ source: ['/'],
+ target: '/blockbeats/flash',
+ },
+ {
+ title: '新闻',
+ docs: 'https://docs.rsshub.app/new-media.html#lu-dong-xin-wen-kuai-xun',
+ source: ['/'],
+ target: '/blockbeats/news',
+ },
+ ],
+ },
+};
diff --git a/lib/v2/blockbeats/router.js b/lib/v2/blockbeats/router.js
new file mode 100644
index 000000000..91b8719d6
--- /dev/null
+++ b/lib/v2/blockbeats/router.js
@@ -0,0 +1,3 @@
+module.exports = function (router) {
+ router.get('/:channel?', require('./index'));
+};