mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-06 05:03:44 +08:00
feat:开眼首页 (#2699)
This commit is contained in:
@@ -206,6 +206,12 @@ pageClass: routes
|
||||
|
||||
<Route author="Songkeys" example="/gaoqing/latest" path="/gaoqing/latest"/>
|
||||
|
||||
## 开眼
|
||||
|
||||
### 每日精选
|
||||
|
||||
<Route author="SunShinenny" example="/kaiyan/index" path="/kaiyan/index"/>
|
||||
|
||||
## 猫眼电影
|
||||
|
||||
### 正在热映
|
||||
|
||||
@@ -1098,6 +1098,32 @@ type 为 all 时,category 参数不支持 cost 和 free
|
||||
|
||||
</Route>
|
||||
|
||||
## 站酷
|
||||
|
||||
### 推荐
|
||||
|
||||
<Route author="junbaor" example="/zcool/recommend/all" path="/zcool/recommend/:type" :paramsDesc="['推荐类型,详见下面的表格']">
|
||||
|
||||
推荐类型
|
||||
|
||||
| all | home | edit |
|
||||
| -------- | -------- | -------- |
|
||||
| 全部推荐 | 首页推荐 | 编辑推荐 |
|
||||
|
||||
</Route>
|
||||
|
||||
### 作品总榜单
|
||||
|
||||
<Route author="junbaor" example="/zcool/top" path="/zcool/top"/>
|
||||
|
||||
### 用户作品
|
||||
|
||||
<Route author="junbaor" example="/zcool/user/baiyong" path="/zcool/user/:uname" :paramsDesc="['个性域名前缀']">
|
||||
|
||||
例如: 站酷的个人主页 `https://baiyong.zcool.com.cn` 对应 rss 路径 `/zcool/user/baiyong`
|
||||
|
||||
</Route>
|
||||
|
||||
## 正版中国
|
||||
|
||||
### 分类列表
|
||||
@@ -1145,29 +1171,3 @@ type 为 all 时,category 参数不支持 cost 和 free
|
||||
### 全文
|
||||
|
||||
<Route author="HenryQW" example="/zzz" path="/zzz/index"/>
|
||||
|
||||
## 站酷
|
||||
|
||||
### 推荐
|
||||
|
||||
<Route author="junbaor" example="/zcool/recommend/all" path="/zcool/recommend/:type" :paramsDesc="['推荐类型,详见下面的表格']">
|
||||
|
||||
推荐类型
|
||||
|
||||
| all | home | edit |
|
||||
| -------- | -------- | -------- |
|
||||
| 全部推荐 | 首页推荐 | 编辑推荐 |
|
||||
|
||||
</Route>
|
||||
|
||||
### 作品总榜单
|
||||
|
||||
<Route author="junbaor" example="/zcool/top" path="/zcool/top"/>
|
||||
|
||||
### 用户作品
|
||||
|
||||
<Route author="junbaor" example="/zcool/user/baiyong" path="/zcool/user/:uname" :paramsDesc="['个性域名前缀']">
|
||||
|
||||
例如: 站酷的个人主页 `https://baiyong.zcool.com.cn` 对应 rss 路径 `/zcool/user/baiyong`
|
||||
|
||||
</Route>
|
||||
|
||||
@@ -1579,4 +1579,7 @@ router.get('/yidoutang/guide', require('./routes/yidoutang/guide.js'));
|
||||
router.get('/yidoutang/mtest', require('./routes/yidoutang/mtest.js'));
|
||||
router.get('/yidoutang/case/:type', require('./routes/yidoutang/case.js'));
|
||||
|
||||
// 开眼
|
||||
router.get('/kaiyan/index', require('./routes/kaiyan/index'));
|
||||
|
||||
module.exports = router;
|
||||
|
||||
50
lib/routes/kaiyan/index.js
Normal file
50
lib/routes/kaiyan/index.js
Normal file
@@ -0,0 +1,50 @@
|
||||
const got = require('@/utils/got');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
// const id = ctx.params.id;
|
||||
const api_url = `https://baobab.kaiyanapp.com/api/v5/index/tab/allRec`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: api_url,
|
||||
});
|
||||
const list = response.data.itemList[0].data.itemList;
|
||||
const out = await Promise.all(
|
||||
list.map(async (item) => {
|
||||
if (item.type === 'followCard') {
|
||||
// 截取Json一部分
|
||||
const content = item.data.content;
|
||||
// 得到需要的RSS信息
|
||||
const title = content.data.title; // 标题
|
||||
const date = item.data.header.time; // 发布日期
|
||||
const itemUrl = `<video src="${content.data.playUrl}" controls="controls"></video>`; // 视频链接
|
||||
const imgUrl = `<img src="${content.data.cover.feed}" />`; // 图片链接
|
||||
const author = content.data.author.name; // 作者
|
||||
const description = content.data.description + '<br/>' + imgUrl + '<br/>' + itemUrl; // 拼接出描述
|
||||
|
||||
const cache = await ctx.cache.get(itemUrl); // 得到全局中的缓存信息
|
||||
// 判断缓存是否存在,如果存在即跳过此次获取的信息
|
||||
if (cache) {
|
||||
return Promise.resolve(JSON.parse(cache));
|
||||
}
|
||||
// 设置 RSS feed item
|
||||
const single = {
|
||||
title: title,
|
||||
link: itemUrl,
|
||||
author: author,
|
||||
description: description,
|
||||
pubDate: new Date(date).toUTCString(),
|
||||
};
|
||||
// 设置缓存
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `开眼精选`,
|
||||
link: '',
|
||||
description: '开眼每日精选',
|
||||
item: out,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user