mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-09 14:40:23 +08:00
feat: add 观察者网观学院 (#6143)
This commit is contained in:
@@ -797,6 +797,16 @@ others = 热点新闻 + 滚动新闻
|
||||
|
||||
</Route>
|
||||
|
||||
### 观学院
|
||||
|
||||
<Route author="nczitzk" example="/guancha/member/recommend" path="/guancha/member/:caty?" :paramsDesc="['分类,见下表']">
|
||||
|
||||
| 精选 | 观书堂 | 在线课 | 观学院 |
|
||||
| --------- | ------ | ------- | -------- |
|
||||
| recommend | books | courses | huodongs |
|
||||
|
||||
</Route>
|
||||
|
||||
### 风闻话题
|
||||
|
||||
<Route author="occupy5 nczitzk" example="/guancha/topic/110/1" path="/guancha/topic/:id?/:order?" :paramsDesc="['话题 id,可在URL中找到,默认为全部,即为 `0`', '排序参数,见下表']">
|
||||
|
||||
@@ -1701,6 +1701,7 @@ router.get('/zfrontier/board/:boardId', require('./routes/zfrontier/board_postli
|
||||
|
||||
// 观察者网
|
||||
router.get('/guancha/topic/:id/:order?', require('./routes/guancha/topic'));
|
||||
router.get('/guancha/member/:caty?', require('./routes/guancha/member'));
|
||||
router.get('/guancha/personalpage/:uid', require('./routes/guancha/personalpage'));
|
||||
router.get('/guancha/:caty?', require('./routes/guancha/index'));
|
||||
|
||||
|
||||
71
lib/routes/guancha/member.js
Normal file
71
lib/routes/guancha/member.js
Normal file
@@ -0,0 +1,71 @@
|
||||
const got = require('@/utils/got');
|
||||
|
||||
const title = {
|
||||
recommend: '精选',
|
||||
books: '观书堂',
|
||||
courses: '在线课',
|
||||
huodongs: '观学院',
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const caty = ctx.params.caty || 'recommend';
|
||||
|
||||
const rootUrl = 'https://member.guancha.cn';
|
||||
const apiUrl = `${rootUrl}/zaixianke/home`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: apiUrl,
|
||||
});
|
||||
|
||||
let items;
|
||||
|
||||
switch (caty) {
|
||||
case 'books':
|
||||
items = response.data.data.books.map((item) => ({
|
||||
title: item.title,
|
||||
link: `${rootUrl}/guanshutang/summary.html?id=${item.id}`,
|
||||
description: `<img src="${item.cover}"><p>[${item.audio_time}] ${item.desc_short}</p>`,
|
||||
pubDate: new Date(parseInt(item.cover.split('/').pop().substr(0, 10)) * 1000).toUTCString(),
|
||||
}));
|
||||
break;
|
||||
|
||||
case 'courses':
|
||||
items = response.data.data.courses.data.map((item) => {
|
||||
let description = '',
|
||||
pubDate = new Date(0);
|
||||
|
||||
for (const i of item.items) {
|
||||
const newPubDate = new Date(i.publish_time);
|
||||
pubDate = pubDate > newPubDate ? pubDate : newPubDate;
|
||||
description += `<a href="${rootUrl}/zaixianke/content.html?id=${i.id}">${i.title}</a><br>`;
|
||||
}
|
||||
|
||||
return {
|
||||
title: item.name,
|
||||
link: `${rootUrl}/zaixianke/summary.html?id=${item.id}`,
|
||||
author: item.author_name,
|
||||
description: `<img src="${item.cover}"><p>${item.desc_short}</p><br>${description}`,
|
||||
pubDate: pubDate.toUTCString(),
|
||||
};
|
||||
});
|
||||
break;
|
||||
|
||||
default:
|
||||
items = response.data.data[caty].map((item) => ({
|
||||
title: item.title,
|
||||
link: item.jump_url,
|
||||
author: item.author_name,
|
||||
description: `<img src="${item.big_pic}"><p>${item.summary}</p>`,
|
||||
enclosure_url: item.media_url,
|
||||
enclosure_length: item.media_size,
|
||||
enclosure_type: 'audio/mpeg',
|
||||
pubDate: new Date(item.created_at * 1000).toUTCString(),
|
||||
}));
|
||||
}
|
||||
|
||||
ctx.state.data = {
|
||||
title: `观学院 - ${title[caty]}`,
|
||||
link: `${rootUrl}/index.html`,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user