From 3aae8f06bdd19be48514bce0f779cce29b451d3e Mon Sep 17 00:00:00 2001
From: Ethan Shen <42264778+nczitzk@users.noreply.github.com>
Date: Tue, 23 Aug 2022 02:57:30 +0800
Subject: [PATCH] =?UTF-8?q?feat(route):=20add=20=E8=99=8E=E5=97=8524?=
=?UTF-8?q?=E5=B0=8F=E6=97=B6=20(#10560)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
docs/new-media.md | 4 ++++
lib/v2/huxiu/maintainer.js | 1 +
lib/v2/huxiu/moment.js | 40 +++++++++++++++++++++++++++++++
lib/v2/huxiu/radar.js | 6 +++++
lib/v2/huxiu/router.js | 1 +
lib/v2/huxiu/templates/moment.art | 16 +++++++++++++
6 files changed, 68 insertions(+)
create mode 100644 lib/v2/huxiu/moment.js
create mode 100644 lib/v2/huxiu/templates/moment.art
diff --git a/docs/new-media.md b/docs/new-media.md
index c81794c7a3..8a7ff2eed1 100644
--- a/docs/new-media.md
+++ b/docs/new-media.md
@@ -2274,6 +2274,10 @@ others = 热点新闻 + 滚动新闻
+### 24 小时
+
+
+
### 标签
diff --git a/lib/v2/huxiu/maintainer.js b/lib/v2/huxiu/maintainer.js
index 3df026395c..2e6f15e8f4 100644
--- a/lib/v2/huxiu/maintainer.js
+++ b/lib/v2/huxiu/maintainer.js
@@ -2,6 +2,7 @@ module.exports = {
'/article': ['HenryQW'],
'/author/:id': ['HenryQW'],
'/collection/:id': ['AlexdanerZe'],
+ '/moment': ['nczitzk'],
'/tag/:id': ['xyqfer', 'HenryQW'],
'/search/:keyword': ['xyqfer', 'HenryQW'],
};
diff --git a/lib/v2/huxiu/moment.js b/lib/v2/huxiu/moment.js
new file mode 100644
index 0000000000..63403aa27a
--- /dev/null
+++ b/lib/v2/huxiu/moment.js
@@ -0,0 +1,40 @@
+const got = require('@/utils/got');
+const { parseDate } = require('@/utils/parse-date');
+const { art } = require('@/utils/render');
+const path = require('path');
+
+module.exports = async (ctx) => {
+ const rootUrl = 'https://www.huxiu.com';
+ const currentUrl = `${rootUrl}/moment`;
+ const apiRootUrl = 'https://moment-api.huxiu.com';
+ const apiUrl = `${apiRootUrl}/web-v2/moment/feed`;
+
+ const response = await got({
+ method: 'post',
+ url: apiUrl,
+ form: {
+ last_dateline: parseInt(new Date().getTime() / 1000),
+ platform: 'www',
+ is_ai: 0,
+ },
+ });
+
+ const items = response.data.data.moment_list.datalist[0].datalist.map((item) => ({
+ title: item.content,
+ link: item.share_url,
+ author: item.user_info.username,
+ pubDate: parseDate(item.publish_time * 1000),
+ description: art(path.join(__dirname, 'templates/moment.art'), {
+ description: item.content,
+ images: item.img_urls,
+ video: item.video,
+ comments: item.comment,
+ }),
+ }));
+
+ ctx.state.data = {
+ title: '虎嗅 - 24小时',
+ link: currentUrl,
+ item: items,
+ };
+};
diff --git a/lib/v2/huxiu/radar.js b/lib/v2/huxiu/radar.js
index 7c73149684..6c79dce118 100644
--- a/lib/v2/huxiu/radar.js
+++ b/lib/v2/huxiu/radar.js
@@ -8,6 +8,12 @@ module.exports = {
source: ['/article', '/'],
target: '/huxiu/article',
},
+ {
+ title: '24小时',
+ docs: 'https://docs.rsshub.app/new-media.html#hu-xiu',
+ source: ['/moment', '/'],
+ target: '/huxiu/moment',
+ },
{
title: '标签',
docs: 'https://docs.rsshub.app/new-media.html#hu-xiu',
diff --git a/lib/v2/huxiu/router.js b/lib/v2/huxiu/router.js
index 954a028a90..f1fe6db949 100644
--- a/lib/v2/huxiu/router.js
+++ b/lib/v2/huxiu/router.js
@@ -2,6 +2,7 @@ module.exports = (router) => {
router.get('/article', require('./article'));
router.get('/author/:id', require('./author'));
router.get('/collection/:id', require('./collection'));
+ router.get('/moment', require('./moment'));
router.get('/tag/:id', require('./tag'));
router.get('/search/:keyword', require('./search'));
};
diff --git a/lib/v2/huxiu/templates/moment.art b/lib/v2/huxiu/templates/moment.art
new file mode 100644
index 0000000000..6a0c4ca04d
--- /dev/null
+++ b/lib/v2/huxiu/templates/moment.art
@@ -0,0 +1,16 @@
+{{@ description }}
+{{ if images }}
+{{ each images image }}
+
+{{ /each }}
+{{ /if }}
+{{ if video }}
+
+{{ /if }}
+{{ if comments }}
+{{ each comments.datalist comment }}
+
{{ comment.user_info.username }}: {{ comment.content }} ({{ comment.show_time }})
+{{ /each }}
+{{ /if }}
\ No newline at end of file