新增少数派 Shortcuts Gallery (#772)

https://github.com/DIYgod/RSSHub/issues/771
This commit is contained in:
Andie
2018-09-23 14:38:05 +08:00
committed by DIYgod
parent 4b01eddc43
commit 7f493670b9
3 changed files with 31 additions and 0 deletions

View File

@@ -1641,6 +1641,8 @@ IATA 国际航空运输协会机场代码, 参见[维基百科 国际航空运
</route>
<route name="Shortcuts Gallery" author="Andiedie" example="/sspai/shortcuts" path="/sspai/shortcuts" />
### 电影首发站
<route name="电影首发站" author="epirus" example="/dysfz/index" path="/dysfz/index">

View File

@@ -560,6 +560,7 @@ router.get('/douyin/user/:id', require('./routes/douyin/user'));
// 少数派 sspai
router.get('/sspai/series', require('./routes/sspai/series'));
router.get('/sspai/shortcuts', require('./routes/sspai/shortcutsGallery'));
// xclient.info
router.get('/xclient/app/:name', require('./routes/xclient/app'));

View File

@@ -0,0 +1,28 @@
const axios = require('../../utils/axios');
module.exports = async (ctx) => {
const {
data: { data: categories },
} = await axios.get('https://shortcuts.sspai.com/api/v1/user/workflow/all/get');
const items = [];
for (const category of categories) {
for (const shortcut of category.data || []) {
items.push({
title: shortcut.name,
description: `作者:<a href="${shortcut.author_url || '#'}">${shortcut.author_id}</a><br/>${decodeURIComponent((shortcut.description || '').replace(/\+/g, '%20'))}`,
pubDate: new Date(shortcut.utime * 1000).toUTCString(),
guid: shortcut.id,
link: shortcut.url,
});
}
}
ctx.state.data = {
title: 'Shortcuts Gallery - 少数派',
link: 'https://shortcuts.sspai.com/#/main/workflow',
description: 'Shortcuts Gallery - 少数派',
item: items,
};
};