diff --git a/lib/v2/agefans/detail.js b/lib/v2/agefans/detail.js index d7ef311fa..b81ae156b 100644 --- a/lib/v2/agefans/detail.js +++ b/lib/v2/agefans/detail.js @@ -1,26 +1,31 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); +const { rootUrl } = require('./utils'); module.exports = async (ctx) => { - const response = await got(`https://www.agemys.cc/detail/${ctx.params.id}`); + const response = await got(`${rootUrl}/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.agemys.cc${$(item).attr('href')}`, - })) - .get(); - items.reverse(); + const ldJson = JSON.parse($('script[type="application/ld+json"]').text()); + + const items = $('.video_detail_episode') + .first() + .find('li') + .toArray() + .map((item) => { + item = $(item); + const a = item.find('a'); + return { + title: a.text(), + link: a.attr('href').replace('http://', 'https://'), + }; + }) + .reverse(); ctx.state.data = { - title: `AGE动漫 - ${$('.detail_imform_name').text()}`, - link: `https://www.agemys.cc/detail/${ctx.params.id}`, - description: $('.detail_imform_desc_pre').text(), + title: `AGE动漫 - ${ldJson.name}`, + link: `${rootUrl}/detail/${ctx.params.id}`, + description: ldJson.description, item: items, }; }; diff --git a/lib/v2/agefans/radar.js b/lib/v2/agefans/radar.js index 33feb1378..8acd8c3ef 100644 --- a/lib/v2/agefans/radar.js +++ b/lib/v2/agefans/radar.js @@ -1,19 +1,22 @@ -module.exports = { - 'agemys.cc': { - _name: 'AGE动漫', - '.': [ - { - title: '最近更新', - docs: 'https://docs.rsshub.app/anime.html#age-dong-man', - source: ['/update', '/'], - target: '/agefans/update', - }, - { - title: '番剧详情', - docs: 'https://docs.rsshub.app/anime.html#age-dong-man', - source: ['/detail/:id'], - target: '/agefans/detail/:id', - }, - ], - }, +const ageFans = { + _name: 'AGE动漫', + '.': [ + { + title: '最近更新', + docs: 'https://docs.rsshub.app/anime.html#age-dong-man', + source: ['/update', '/'], + target: '/agefans/update', + }, + { + title: '番剧详情', + docs: 'https://docs.rsshub.app/anime.html#age-dong-man', + source: ['/detail/:id'], + target: '/agefans/detail/:id', + }, + ], +}; + +module.exports = { + 'agemys.cc': ageFans, + 'agemys.org': ageFans, }; diff --git a/lib/v2/agefans/update.js b/lib/v2/agefans/update.js index a30ce6c3f..03a9a1129 100644 --- a/lib/v2/agefans/update.js +++ b/lib/v2/agefans/update.js @@ -1,23 +1,24 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); +const { rootUrl } = require('./utils'); module.exports = async (ctx) => { - const rootUrl = 'https://www.agemys.cc'; const currentUrl = `${rootUrl}/update`; const response = await got(currentUrl); const $ = cheerio.load(response.data); - const list = $('.anime_icon2_name a') - .map((_, item) => { + const list = $('.video_item') + .toArray() + .map((item) => { item = $(item); + const link = item.find('a').attr('href').replace('http://', 'https://'); return { title: item.text(), - link: `${rootUrl}${item.attr('href')}`, - guid: `${rootUrl}${item.attr('href')}#${item.parent().prev().find('.anime_icon1_name1').text()}`, + link, + guid: `${link}#${item.find('.video_item--info').text()}`, }; - }) - .get(); + }); const items = await Promise.all( list.map((item) => @@ -25,7 +26,15 @@ module.exports = async (ctx) => { const detailResponse = await got(item.link); const content = cheerio.load(detailResponse.data); - item.description = content('.div_left').html(); + content('img').each((_, ele) => { + if (ele.attribs['data-original']) { + ele.attribs.src = ele.attribs['data-original']; + delete ele.attribs['data-original']; + } + }); + content('.video_detail_collect').remove(); + + item.description = content('.video_detail_left').html(); return item; }) diff --git a/lib/v2/agefans/utils.js b/lib/v2/agefans/utils.js new file mode 100644 index 000000000..e8e606efc --- /dev/null +++ b/lib/v2/agefans/utils.js @@ -0,0 +1,5 @@ +const rootUrl = 'https://www.agemys.org'; + +module.exports = { + rootUrl, +};