From a7702e5a894b125a6c83cfe2704af48faa824d01 Mon Sep 17 00:00:00 2001 From: nczitzk Date: Mon, 8 Mar 2021 22:35:00 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20AGE=E5=8A=A8=E6=BC=AB=E6=9C=80=E8=BF=91?= =?UTF-8?q?=E6=9B=B4=20=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/anime.md | 4 +++ lib/router.js | 4 ++- lib/routes/agefans/update.js | 47 ++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 lib/routes/agefans/update.js diff --git a/docs/anime.md b/docs/anime.md index cf25578ecba2bd..944dbf1c6ddfa6 100644 --- a/docs/anime.md +++ b/docs/anime.md @@ -35,6 +35,10 @@ pageClass: routes ## AGE 动漫 +### 最近更新 + + + ### 番剧详情 diff --git a/lib/router.js b/lib/router.js index fcad8a96ccb3cf..f7741ff7ee98d0 100644 --- a/lib/router.js +++ b/lib/router.js @@ -2778,6 +2778,7 @@ router.get('/swjtu/tl/news', require('./routes/swjtu/tl/news')); // AGE动漫 router.get('/agefans/detail/:id', require('./routes/agefans/detail')); +router.get('/agefans/update', require('./routes/agefans/update')); // Checkra1n router.get('/checkra1n/releases', require('./routes/checkra1n/releases')); @@ -3910,8 +3911,9 @@ router.get('/tingshen', require('./routes/tingshen/tingshen')); router.get('/gov/mohrss/sbjm/:category?', require('./routes/gov/mohrss/sbjm')); // 深影译站 -router.get('/shinybbs/:id?', require('./routes/shinybbs/index')); router.get('/shinybbs/latest', require('./routes/shinybbs/latest')); +router.get('/shinybbs/page/:id?', require('./routes/shinybbs/index')); +router.get('/shinybbs', require('./routes/shinybbs/index')); // 天眼查 router.get('/tianyancha/hot', require('./routes/tianyancha/hot')); diff --git a/lib/routes/agefans/update.js b/lib/routes/agefans/update.js new file mode 100644 index 00000000000000..b062210ff06b98 --- /dev/null +++ b/lib/routes/agefans/update.js @@ -0,0 +1,47 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const rootUrl = 'https://www.agefans.net'; + const currentUrl = `${rootUrl}/update`; + const response = await got({ + method: 'get', + url: currentUrl, + }); + + const $ = cheerio.load(response.data); + + const list = $('.anime_icon2_name a') + .slice(0, 15) + .map((_, item) => { + item = $(item); + return { + title: item.text(), + link: `${rootUrl}${item.attr('href')}`, + }; + }) + .get(); + + const items = await Promise.all( + list.map( + async (item) => + await ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got({ + method: 'get', + url: item.link, + }); + const content = cheerio.load(detailResponse.data); + + item.description = content('.div_left').html(); + + return item; + }) + ) + ); + + ctx.state.data = { + title: $('title').text(), + link: currentUrl, + item: items, + }; +};