feat: add agefans.tv detail (#4291)
This commit is contained in:
@@ -39,6 +39,12 @@ pageClass: routes
|
||||
|
||||
<Route author="wdssmq" example="/acfun/user/video/14450522" path="/acfun/user/video/:id" :paramsDesc="['用户 UID']"/>
|
||||
|
||||
## AGE 动漫
|
||||
|
||||
### 番剧详情
|
||||
|
||||
<Route author="s2marine" example="/agefans/detail/20200035" path="/agefans/detail/:id" :paramsDesc="['番剧 id,对应详情 URL 中找到']"/>
|
||||
|
||||
## bilibili
|
||||
|
||||
见 [#bilibili](/social-media.html#bilibili)
|
||||
|
||||
@@ -2409,6 +2409,9 @@ router.get('/hubu/news/:type', require('./routes/universities/hubu/news'));
|
||||
// 大连海事大学
|
||||
router.get('/dlmu/news/:type', require('./routes/universities/dlmu/news'));
|
||||
|
||||
// AGE动漫
|
||||
router.get('/agefans/detail/:id', require('./routes/agefans/detail'));
|
||||
|
||||
// Checkra1n
|
||||
router.get('/checkra1n/releases', require('./routes/checkra1n/releases'));
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: `https://www.agefans.tv/detail/${ctx.params.id}`,
|
||||
});
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const defaultIdx = parseInt($('#DEF_PLAYINDEX').get(0).children[0].data);
|
||||
const items = $('#main0 div')
|
||||
.filter((idx) => defaultIdx === idx)
|
||||
.find('a')
|
||||
.map((idx, item) => ({
|
||||
title: $(item).text(),
|
||||
description: $(item).text(),
|
||||
link: `https://www.agefans.tv/${$(item).attr('href')}`,
|
||||
}))
|
||||
.get();
|
||||
items.reverse();
|
||||
|
||||
ctx.state.data = {
|
||||
title: `ACG动漫 - ${$('.detail_imform_name').text()}`,
|
||||
link: `https://www.agefans.tv/detail/${ctx.params.id}`,
|
||||
description: $('.detail_imform_desc_pre').text(),
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user