diff --git a/docs/multimedia.md b/docs/multimedia.md index 6431aa1bc0..9d6c3271f9 100644 --- a/docs/multimedia.md +++ b/docs/multimedia.md @@ -202,6 +202,16 @@ pageClass: routes +## 猫眼电影 + +### 正在热映 + + + +### 即将上映 + + + ## 柠檬 私房歌 (ningmeng.name) ### 私房歌 diff --git a/lib/router.js b/lib/router.js index 5e4017e01d..8a1d159841 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1351,4 +1351,8 @@ router.get('/algocasts', require('./routes/algocasts/all')); // aqicn router.get('/aqicn/:city', require('./routes/aqicn/index')); +// 猫眼电影 +router.get('/maoyan/hot', require('./routes/maoyan/hot')); +router.get('/maoyan/upcoming', require('./routes/maoyan/upcoming')); + module.exports = router; diff --git a/lib/routes/maoyan/hot.js b/lib/routes/maoyan/hot.js new file mode 100644 index 0000000000..2e7afd91d1 --- /dev/null +++ b/lib/routes/maoyan/hot.js @@ -0,0 +1,28 @@ +const axios = require('@/utils/axios'); + +module.exports = async (ctx) => { + const response = await axios({ + method: 'get', + url: 'https://m.maoyan.com/ajax/movieOnInfoList', + }); + const data = response.data.movieList; + const items = await Promise.all( + data.map(async (item) => { + const rating = item.sc > 0 ? `评分:${item.sc}` : ''; + + return { + title: `${item.nm} ${rating}`, + description: `
${rating}
演员:${item.star}
上映信息:${item.showInfo}`, + link: `https://maoyan.com/films/${item.id}`, + pubDate: new Date(item.rt).toUTCString(), + }; + }) + ); + + ctx.state.data = { + title: `猫眼电影 - 正在热映`, + link: `https://maoyan.com/films`, + description: `猫眼电影 - 正在热映`, + item: items, + }; +}; diff --git a/lib/routes/maoyan/upcoming.js b/lib/routes/maoyan/upcoming.js new file mode 100644 index 0000000000..42710b812a --- /dev/null +++ b/lib/routes/maoyan/upcoming.js @@ -0,0 +1,24 @@ +const axios = require('@/utils/axios'); + +module.exports = async (ctx) => { + const response = await axios({ + method: 'get', + url: 'https://m.maoyan.com/ajax/comingList?token=', + }); + const data = response.data.coming; + const items = await Promise.all( + data.map(async (item) => ({ + title: `${item.nm} ${item.comingTitle}`, + description: `
演员:${item.star}
上映信息:${item.showInfo || item.comingTitle}`, + link: `https://maoyan.com/films/${item.id}`, + pubDate: new Date(item.rt).toUTCString(), + })) + ); + + ctx.state.data = { + title: `猫眼电影 - 正在热映`, + link: `https://maoyan.com/films?showType=2`, + description: `猫眼电影 - 正在热映`, + item: items, + }; +};