diff --git a/docs/multimedia.md b/docs/multimedia.md index b07ddca913..42b341e328 100644 --- a/docs/multimedia.md +++ b/docs/multimedia.md @@ -206,6 +206,12 @@ pageClass: routes +## 开眼 + +### 每日精选 + + + ## 猫眼电影 ### 正在热映 diff --git a/docs/other.md b/docs/other.md index afa5bd7ade..efcdc6a063 100644 --- a/docs/other.md +++ b/docs/other.md @@ -1098,6 +1098,32 @@ type 为 all 时,category 参数不支持 cost 和 free +## 站酷 + +### 推荐 + + + +推荐类型 + +| all | home | edit | +| -------- | -------- | -------- | +| 全部推荐 | 首页推荐 | 编辑推荐 | + + + +### 作品总榜单 + + + +### 用户作品 + + + +例如: 站酷的个人主页 `https://baiyong.zcool.com.cn` 对应 rss 路径 `/zcool/user/baiyong` + + + ## 正版中国 ### 分类列表 @@ -1145,29 +1171,3 @@ type 为 all 时,category 参数不支持 cost 和 free ### 全文 - -## 站酷 - -### 推荐 - - - -推荐类型 - -| all | home | edit | -| -------- | -------- | -------- | -| 全部推荐 | 首页推荐 | 编辑推荐 | - - - -### 作品总榜单 - - - -### 用户作品 - - - -例如: 站酷的个人主页 `https://baiyong.zcool.com.cn` 对应 rss 路径 `/zcool/user/baiyong` - - diff --git a/lib/router.js b/lib/router.js index 8b44ef8058..5630a096cd 100644 --- a/lib/router.js +++ b/lib/router.js @@ -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; diff --git a/lib/routes/kaiyan/index.js b/lib/routes/kaiyan/index.js new file mode 100644 index 0000000000..d8fd59a030 --- /dev/null +++ b/lib/routes/kaiyan/index.js @@ -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 = ``; // 视频链接 + const imgUrl = ``; // 图片链接 + const author = content.data.author.name; // 作者 + const description = content.data.description + '
' + imgUrl + '
' + 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, + }; +};