diff --git a/docs/new-media.md b/docs/new-media.md
index a7b30a0e44..afebb08457 100644
--- a/docs/new-media.md
+++ b/docs/new-media.md
@@ -54,7 +54,7 @@ pageClass: routes
### 主题文章
-
+
### 搜索文章
diff --git a/lib/v2/36kr/maintainer.js b/lib/v2/36kr/maintainer.js
index 2062fa2723..9a9c95a57a 100644
--- a/lib/v2/36kr/maintainer.js
+++ b/lib/v2/36kr/maintainer.js
@@ -1,7 +1,7 @@
module.exports = {
- '/motif/:mid': ['nczitzk'],
+ '/motif/:id': ['nczitzk'],
'/news/:category?': ['nczitzk'],
'/newsflashes': ['hillerliao'],
'/search/article/:keyword': ['xyqfer', 'kt286', 'nczitzk'],
- '/user/:uid': ['nczitzk'],
+ '/user/:id': ['nczitzk'],
};
diff --git a/lib/v2/36kr/motif.js b/lib/v2/36kr/motif.js
index 4d478b9833..7b9b909863 100644
--- a/lib/v2/36kr/motif.js
+++ b/lib/v2/36kr/motif.js
@@ -1,36 +1,57 @@
const got = require('@/utils/got');
const { parseDate } = require('@/utils/parse-date');
+const CryptoJS = require('crypto-js');
module.exports = async (ctx) => {
- const motifUrl = `https://36kr.com/motif/${ctx.params.mid}`;
+ const id = ctx.params.id;
+
+ const rootUrl = 'https://36kr.com';
+ const currentUrl = `${rootUrl}/motif/${id}`;
+
const response = await got({
method: 'get',
- url: motifUrl,
+ url: currentUrl,
});
- const data = JSON.parse(response.data.match(/"motifDetailData":{"code":0,"data":(.*?)},"channel":/)[1]);
- const motifInfo = data.motifInfo.data;
- const motifArticleList = data.motifArticleList.data.itemList;
- const articleList = motifArticleList.map((item) => ({
+ const data = JSON.parse(response.data.match(/"motifDetailData":{"code":0,"data":(.*)},"channel"/)[1]);
+
+ let items = data.motifArticleList.data.itemList.map((item) => ({
title: item.templateMaterial.widgetTitle,
- link: `https://36kr.com/${item.route.split('?')[0] === 'detail_video' ? 'video' : 'p'}/${item.itemId}`,
+ link: `${rootUrl}/p/${item.itemId}`,
pubDate: parseDate(item.templateMaterial.publishTime),
}));
+ items = await Promise.all(
+ items.map((item) =>
+ ctx.cache.tryGet(item.link, async () => {
+ const detailResponse = await got({
+ method: 'get',
+ url: item.link,
+ });
+
+ const key = CryptoJS.enc.Utf8.parse('efabccee-b754-4c');
+ const cipherText = detailResponse.data.match(/{"state":"(.*)","isEncrypt":true}/)[1];
+
+ const content = JSON.parse(
+ CryptoJS.AES.decrypt(cipherText, key, {
+ mode: CryptoJS.mode.ECB,
+ padding: CryptoJS.pad.Pkcs7,
+ })
+ .toString(CryptoJS.enc.Utf8)
+ .toString()
+ ).articleDetail.articleDetailData.data;
+
+ item.author = content.author;
+ item.description = content.widgetContent;
+
+ return item;
+ })
+ )
+ );
+
ctx.state.data = {
- title: `36氪专题 - ${motifInfo.categoryTitle}`,
- link: motifUrl,
- item: await Promise.all(
- articleList.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
- const contentResponse = await got({ method: 'get', url: item.link });
- const result = contentResponse.data.match(/"articleDetailData":(.*?),"articleRecommendData":/) || contentResponse.data.match(/"videoDetail":(.*?),"authorVideos":/);
- const contentData = JSON.parse(result[1]);
- item.description = contentData.data.widgetContent;
- return item;
- })
- )
- ),
- description: motifInfo.categoryTitle,
+ title: `36kr - ${data.motifInfo.data.categoryTitle}`,
+ link: currentUrl,
+ item: items,
};
};
diff --git a/lib/v2/36kr/router.js b/lib/v2/36kr/router.js
index bfc5807f4e..223f81cc0e 100644
--- a/lib/v2/36kr/router.js
+++ b/lib/v2/36kr/router.js
@@ -1,5 +1,5 @@
module.exports = (router) => {
- router.get('/motif/:mid', require('./motif'));
+ router.get('/motif/:id', require('./motif'));
router.get('/news/:category?', require('./news'));
router.get('/newsflashes', require('./newsflashes'));
router.get('/search/article/:keyword', require('./search/article'));