From 066e8f5b584c6fbd18c6ab71b229d690c6056fe4 Mon Sep 17 00:00:00 2001 From: Henry Wang Date: Mon, 27 May 2019 04:07:51 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E7=8C=AB=E7=9C=BC?= =?UTF-8?q?=E7=94=B5=E5=BD=B1=20(#2234)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/multimedia.md | 10 ++++++++++ lib/router.js | 4 ++++ lib/routes/maoyan/hot.js | 28 ++++++++++++++++++++++++++++ lib/routes/maoyan/upcoming.js | 24 ++++++++++++++++++++++++ 4 files changed, 66 insertions(+) create mode 100644 lib/routes/maoyan/hot.js create mode 100644 lib/routes/maoyan/upcoming.js 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, + }; +};