feat: add 场库今日精选 (#4981)

This commit is contained in:
Wenmoux 2020-06-14 22:00:54 +08:00 committed by GitHub
parent 3558b68e14
commit 48d6ec476e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 47 additions and 0 deletions

View File

@ -534,3 +534,9 @@ pageClass: routes
### 影视
<Route author="DIYgod" example="/zimuzu/resource/37031" path="/zimuzu/resource/:id?" :paramsDesc="['影视 id对应影视的 URL 中找到,为空时输出最近更新']" supportBT="1"/>
## 场库
### 今日精选
<Route author="Wenmoux" example="/changku" path="/changku"/>

View File

@ -2861,4 +2861,7 @@ router.get('/jike/user/:id', require('./routes/jike/user'));
// 网易新闻
router.get('/netease/news/rank/:category?/:type?/:time?', require('./routes/netease/news/rank'));
// 场库
router.get('/changku', require('./routes/changku/index'));
module.exports = router;

View File

@ -0,0 +1,38 @@
const got = require('@/utils/got');
module.exports = async (ctx) => {
const url = `https://app.vmovier.com/apiv3/index/getIndexPosts/lastid/`;
const config = {
headers: {
'user-agent': 'VmovierApp 5.7.7 / Android 10 / WIFI / 1080*2175 / 2.75',
'content-type': 'application/x-www-form-urlencoded',
},
};
const res = await got({
method: 'get',
url: url,
});
const items = await Promise.all(
res.data.data.list.map(async (list) => {
const title = list.title;
const link = `https://app.vmovier.com/apiv3/post/view?postid=${list.postid}`;
const description = await ctx.cache.tryGet(link, async () => {
const res = await got.get(link, config);
const playurl = res.data.data.content_video[0].progressive[0].url;
const desc = `<video src='${playurl}' controls='controls' width='100%'></video><p>${res.data.data.intro}</p><img src='${res.data.data.image}' width='200'>`;
return desc;
});
return Promise.resolve({
title: title,
description: description,
author: list.creator_username,
link: link,
});
})
);
ctx.state.data = {
title: `场库-每日精选`,
link: url,
description: '场库-每日精选',
item: items,
};
};