feat: 增加 Instagram 快拍 Stories (#3018)
This commit is contained in:
parent
3b442f3c84
commit
b63d42a7dd
|
|
@ -284,6 +284,10 @@ pageClass: routes
|
|||
|
||||
<Route author="widyakumara" path="/instagram/tag/:tag" example="/instagram/tag/urbantoys" :paramsDesc="['标签名']" anticrawler="1"/>
|
||||
|
||||
### 快拍 Stories
|
||||
|
||||
<Route author="Maecenas" path="/instagram/story/:username" example="/instagram/story/instagram" :paramsDesc="['用户名']"/>
|
||||
|
||||
## Matters
|
||||
|
||||
### 最新排序
|
||||
|
|
|
|||
|
|
@ -172,6 +172,7 @@ router.get('/twitter/followings/:id', require('./routes/twitter/followings'));
|
|||
// Instagram
|
||||
router.get('/instagram/user/:id', require('./routes/instagram/user'));
|
||||
router.get('/instagram/tag/:tag', require('./routes/instagram/tag'));
|
||||
router.get('/instagram/story/:username', require('./routes/instagram/story'));
|
||||
|
||||
// Youtube
|
||||
router.get('/youtube/user/:username/:embed?', require('./routes/youtube/user'));
|
||||
|
|
|
|||
|
|
@ -0,0 +1,34 @@
|
|||
const got = require('@/utils/got');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const username = ctx.params.username;
|
||||
|
||||
const response = (await got({
|
||||
method: 'get',
|
||||
url: `https://api.storiesig.com/stories/${username}`,
|
||||
headers: {
|
||||
Referer: `https://storiesig.com/?username=${username}`,
|
||||
},
|
||||
})).data;
|
||||
|
||||
const items = response.items.map((item) => {
|
||||
const image = item.image_versions2 && item.image_versions2.candidates[0].url;
|
||||
const video = item.video_versions && item.video_versions[0].url;
|
||||
|
||||
const description = item.video_versions ? `<video src="${video}" width="100%" controls="controls" poster="${image}">Your RSS reader does not support video playback.</video>` : `<img src="${image}" rel="no-referrer">`;
|
||||
const pubDate = new Date(item.taken_at * 1000).toUTCString();
|
||||
|
||||
return {
|
||||
title: `[快拍/Stories]${item.caption || ''} ${pubDate}`,
|
||||
description,
|
||||
pubDate,
|
||||
link: `https://www.instagram.com/stories/${username}/${item.id}`,
|
||||
};
|
||||
});
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${response.user.full_name}'s stories on Instagram`,
|
||||
link: `https://www.instagram.com/stories/${username}/`,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue