Add Feed Source GeekTime (极客时间) (#146)

This commit is contained in:
FengChang 2018-05-16 21:12:31 +08:00 committed by DIYgod
parent cb966e26a1
commit 6bd9045e7b
4 changed files with 68 additions and 1 deletions

View File

@ -84,6 +84,8 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇
- 开发者头条
- 今天头条
- 独家号
- 极客时间
- 专栏文章
- Disqus
- 评论
- Twitter

View File

@ -217,7 +217,7 @@ order: 排序方式live_time 开播时间online 人气
参数
areaID: 分区ID 分区增删较多,可通过 [分区列表](https://api.live.bilibili.com/room/v1/Area/getList) 查询
areaID: 分区ID 分区增删较多,可通过 [分区列表](https://api.live.bilibili.com/room/v1/Area/getList) 查询
order: 排序方式live_time 开播时间online 人气
@ -639,6 +639,18 @@ key: 产品密钥
参数: id独家号 id可在对应独家号页 URL 中找到
## 极客时间
### 专栏文章
> 极客时间专栏需要付费订阅RSS 仅做更新提醒,不含付费内容。
举例: [https://rsshub.app/geektime/column/48](https://rsshub.app/geektime/column/48)
路由: `/geektime/column/:cid`
参数: cid专栏 id可从[全部专栏](https://time.geekbang.org/paid-content)进入专栏介绍页,在 URL 中找到
## Disqus
### 评论

View File

@ -134,4 +134,7 @@ if (config.youtube && config.youtube.key) {
router.get('/jike/topic/:id', require('./routes/jike/topic'));
router.get('/jike/user/:id', require('./routes/jike/user'));
// 极客时间
router.get('/geektime/column/:cid', require('./routes/geektime/column'));
module.exports = router;

50
routes/geektime/column.js Normal file
View File

@ -0,0 +1,50 @@
const axios = require('axios');
const config = require('../../config');
module.exports = async (ctx) => {
const column_id = ctx.params.cid;
// Get column introduction including column name and description
const intro_response = await axios({
method: 'post',
url: 'https://time.geekbang.org/serv/v1/column/intro',
headers: {
'User-Agent': config.ua,
'Referer': 'https://time.geekbang.org/',
'Content-Type': 'application/json'
},
data: {
cid: column_id
}
});
const intro_data = intro_response.data.data;
// Get latest articles
const latest_response = await axios({
method: 'post',
url: 'https://time.geekbang.org/serv/v1/column/articles/latest',
headers: {
'User-Agent': config.ua,
'Referer': 'https://time.geekbang.org/',
'Content-Type': 'application/json'
},
data: {
cid: column_id
}
});
const articles = latest_response.data.data.list;
ctx.state.data = {
title: intro_data.column_title,
link: `https://time.geekbang.org/column/intro/${column_id}`,
description: intro_data.column_subtitle,
item: articles.map((item) => ({
title: item.article_title,
description: item.article_summary,
pubDate: new Date(item.article_ctime * 1000).toUTCString(),
link: `https://time.geekbang.org/column/article/${item.id}`
})),
};
};