feat(route): 三联生活周刊 (#14127)
* feat(route): 三联生活周刊 * fix: namespace and data acquirement * fix: get article list by api * Update lib/v2/lifeweek/channel.js Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update lib/v2/lifeweek/channel.js Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update lib/v2/lifeweek/tag.js Co-authored-by: Tony <TonyRL@users.noreply.github.com> * fix: rss url * refactor: getRssItem function * Update lib/v2/lifeweek/utils.js --------- Co-authored-by: Changren Wang <changren.wcr@alibaba-inc.com>
This commit is contained in:
parent
0dba566711
commit
a01c645757
|
|
@ -0,0 +1,25 @@
|
|||
const got = require('@/utils/got');
|
||||
const getRssItem = require('./utils');
|
||||
|
||||
const rootApiUrl = 'https://www.lifeweek.com.cn/api/userWebFollow/getFollowTagContentList?type=3&sort=2&tagId';
|
||||
const rootUrl = 'https://www.lifeweek.com.cn/column';
|
||||
const articleRootUrl = 'https://www.lifeweek.com.cn/article';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const channel = ctx.params.id;
|
||||
const url = `${rootApiUrl}=${channel}`;
|
||||
const { data } = await got(url);
|
||||
const result = data.model.articleResponseList;
|
||||
const items = await Promise.all(
|
||||
result.map((item) => {
|
||||
const articleLink = `${articleRootUrl}/${item.id}`;
|
||||
return ctx.cache.tryGet(articleLink, () => getRssItem(item, articleLink));
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: data.model.tagName,
|
||||
link: `${rootUrl}/${channel}`,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
module.exports = {
|
||||
'/channel/:channel': ['changren-wcr'],
|
||||
'/tag/:tag': ['changren-wcr'],
|
||||
};
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
module.exports = {
|
||||
'lifeweek.com.cn': {
|
||||
_name: '三联生活周刊',
|
||||
'.': [
|
||||
{
|
||||
title: '栏目',
|
||||
docs: 'https://docs.rsshub.app/routes/traditional-media#san-lian-sheng-huo-zhou-kan',
|
||||
source: ['/column/:channel'],
|
||||
target: '/lifeweek/channel/:channel',
|
||||
},
|
||||
{
|
||||
title: '标签',
|
||||
docs: 'https://docs.rsshub.app/routes/traditional-media#san-lian-sheng-huo-zhou-kan',
|
||||
source: ['/articleList/:tag'],
|
||||
target: '/lifeweek/tag/:tag',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
module.exports = function (router) {
|
||||
router.get('/channel/:id', require('./channel'));
|
||||
router.get('/tag/:id', require('./tag'));
|
||||
};
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
const got = require('@/utils/got');
|
||||
const getRssItem = require('./utils');
|
||||
const rootApiUrl = 'https://www.lifeweek.com.cn/api/userWebFollow/getFollowTagContentList?type=4&sort=2&tagId';
|
||||
const rootUrl = 'https://www.lifeweek.com.cn/articleList';
|
||||
const articleRootUrl = 'https://www.lifeweek.com.cn/article';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const tag = ctx.params.id;
|
||||
const url = `${rootApiUrl}=${tag}`;
|
||||
const { data } = await got(url);
|
||||
const result = data.model.articleResponseList;
|
||||
const items = await Promise.all(
|
||||
result.map((item) => {
|
||||
const articleLink = `${articleRootUrl}/${item.id}`;
|
||||
return ctx.cache.tryGet(articleLink, () => getRssItem(item, articleLink));
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: data.model.tagName,
|
||||
link: `${rootUrl}/${tag}`,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
const got = require('@/utils/got');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const articleApiRootUrl = 'https://www.lifeweek.com.cn/api/article';
|
||||
|
||||
async function getRssItem(item, articleLink) {
|
||||
const articleApiLink = `${articleApiRootUrl}/${item.id}`;
|
||||
const { data } = await got(articleApiLink);
|
||||
const time = timezone(parseDate(item.pubTime), +8);
|
||||
return {
|
||||
title: item.title,
|
||||
description: data.model.content,
|
||||
link: articleLink,
|
||||
pubDate: time,
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = getRssItem;
|
||||
|
|
@ -1812,6 +1812,28 @@ This route adds the missing photo and Link element. (Offical RSS doesn't have Li
|
|||
| ---- | ---- | ---- | ---- | ---- | -------- |
|
||||
</Route>
|
||||
|
||||
## 三联生活周刊 {#san-lian-sheng-huo-zhou-kan}
|
||||
|
||||
### 栏目 {#san-lian-sheng-huo-zhou-kan-lan-mu}
|
||||
|
||||
提取文章全文,获得更好的阅读体验。支持所有频道,频道名称见 [杂志栏目](https://www.lifeweek.com.cn/classify?type=2)。例如 [调查栏目](https://www.lifeweek.com.cn/column/9) URL 最后的数字为栏目 ID
|
||||
|
||||
<Route author="changren-wcr" example="/lifeweek/channel/9" path="/lifeweek/channel/:channel" paramsDesc={['栏目 ID']}>
|
||||
| 调查 | 热点 | 人物 | 社会 | 经济 | 文化 |
|
||||
| ---- | ---- | ---- | ---- | ---- | ---- |
|
||||
| 9 | 6 | 10 | 2 | 3 | 4 |
|
||||
</Route>
|
||||
|
||||
### 标签 {#san-lian-sheng-huo-zhou-kan-biao-qian}
|
||||
|
||||
提取文章全文,获得更好的阅读体验。支持所有标签,标签名称见 [全部标签](https://www.lifeweek.com.cn/classify?type=1)。例如 [社会调查标签](https://www.lifeweek.com.cn/articleList/122) URL 最后的数字为标签 ID
|
||||
|
||||
<Route author="changren-wcr" example="/lifeweek/tag/122" path="/lifeweek/tag/:tag" paramsDesc={['标签 ID']}>
|
||||
| 社会调查 | 社会 | 经济 | 理财 | 热点 |
|
||||
| -------- | ---- | ---- | ---- | ---- |
|
||||
| 122 | 21 | 73 | 74 | 123 |
|
||||
</Route>
|
||||
|
||||
## 厦门网 {#xia-men-wang}
|
||||
|
||||
### 数字媒体 {#xia-men-wang-shu-zi-mei-ti}
|
||||
|
|
|
|||
Loading…
Reference in New Issue