From 221eefebace3709382fcf241e3d359a904496e08 Mon Sep 17 00:00:00 2001 From: Ethan Shen Date: Mon, 7 Dec 2020 02:08:40 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20add=20=E7=8C=AB=E8=80=B3FM=E6=9C=80?= =?UTF-8?q?=E6=96=B0=E5=B9=BF=E6=92=AD=E5=89=A7=20(#6345)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/multimedia.md | 4 +++ lib/router.js | 1 + lib/routes/missevan/latest.js | 47 +++++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 lib/routes/missevan/latest.js diff --git a/docs/multimedia.md b/docs/multimedia.md index 67f1a6c396..704c1fe6d4 100644 --- a/docs/multimedia.md +++ b/docs/multimedia.md @@ -603,6 +603,10 @@ pageClass: routes +### 最新广播剧 + + + ## 猫眼电影 ### 正在热映 diff --git a/lib/router.js b/lib/router.js index 19a76f4a63..27cb86d79d 100644 --- a/lib/router.js +++ b/lib/router.js @@ -3073,6 +3073,7 @@ router.get('/amazfitwatchfaces/top/:model/:type?/:time?/:sortBy?/:lang?', requir router.get('/amazfitwatchfaces/search/:model/:keyword?/:sortBy?', require('./routes/amazfitwatchfaces/search')); // 猫耳FM +router.get('/missevan/drama/latest', require('./routes/missevan/latest')); router.get('/missevan/drama/:id', require('./routes/missevan/drama')); // Go语言爱好者周刊 diff --git a/lib/routes/missevan/latest.js b/lib/routes/missevan/latest.js new file mode 100644 index 0000000000..b11f6000b8 --- /dev/null +++ b/lib/routes/missevan/latest.js @@ -0,0 +1,47 @@ +const got = require('@/utils/got'); + +module.exports = async (ctx) => { + const link = `https://www.missevan.com/dramaapi/filter?filters=0_0_0_0_0&page=1&order=1&page_size=20`; + const response = await got({ + method: 'get', + url: link, + }); + + const items = await Promise.all( + response.data.info.Datas.map(async (item) => { + const dramaUrl = `https://www.missevan.com/dramaapi/getdrama?drama_id=${item.id}`; + const dramaResponse = await got({ + method: 'get', + url: dramaUrl, + }); + try { + const soundUrl = `https://www.missevan.com/sound/getsound?soundid=${dramaResponse.data.info.episodes.episode[0].sound_id}`; + const soundResponse = await got({ + method: 'get', + url: soundUrl, + }); + const soundData = soundResponse.data.info.sound; + return { + title: item.name + (item.integrity === 3 ? '(已完结)' : '(更新至 ' + item.newest + ')'), + enclosure_url: soundData.soundurl, + enclosure_length: soundData.duration, + enclosure_type: 'audio/mpeg', + image: item.cover, + itunes_author: soundData.username, + itunes_category: '', + link: `https://www.missevan.com/sound/player?id=${dramaResponse.data.info.episodes.episode[0].sound_id}`, + description: `
${soundData.intro}`, + pubDate: new Date(soundData.last_update_time * 1000).toUTCString(), + }; + } catch (err) { + return Promise.resolve(''); + } + }) + ); + + ctx.state.data = { + title: `猫耳FM - 最新广播剧`, + link: `https://www.missevan.com/mdrama`, + item: items, + }; +};