diff --git a/docs/design.md b/docs/design.md index 44f74ac3b6..f8ebf35a2e 100755 --- a/docs/design.md +++ b/docs/design.md @@ -4,6 +4,17 @@ pageClass: routes # 设计 +## Axis Studios + +### Work type + + + +文章内 Work type 指向的栏目地址,比如: 'https://axisstudiosgroup.com/work/full-service-cg-production' 的 tag 为 `full-service-cg-production`,要注意的是 tag 和文章的目录是一样的。 + +有一些 tag 并不经常使用: `Script`, `direction`, `production`, `design-concept` 等等。 + + ## Dribbble ### 流行 diff --git a/docs/en/design.md b/docs/en/design.md index 753ff96ba3..6c53ce873b 100755 --- a/docs/en/design.md +++ b/docs/en/design.md @@ -4,6 +4,18 @@ pageClass: routes # Design +## Axis Studios + +### Work type + + + +Work type URL in articles. Such as: 'https://axisstudiosgroup.com/work/full-service-cg-production' the tag will be `full-service-cg-production`. + +Some tags are rarely used: `Script`, `direction`, `production`, `design-concept` etc。 + + + ## Dribbble ### Popular diff --git a/lib/router.js b/lib/router.js index 3201a42bb2..4feae5240a 100755 --- a/lib/router.js +++ b/lib/router.js @@ -2574,6 +2574,9 @@ router.get('/zhuixinfan/list', require('./routes/zhuixinfan/list')); // scoresaber router.get('/scoresaber/user/:id', require('./routes/scoresaber/user')); +// axis-studios +router.get('/axis-studios/:type/:tag?', require('./routes/axis-studios/work')); + // 人民邮电出版社 router.get('/ptpress/book/:type?', require('./routes/ptpress/book')); diff --git a/lib/routes/axis-studios/work.js b/lib/routes/axis-studios/work.js new file mode 100755 index 0000000000..ea23f61f9a --- /dev/null +++ b/lib/routes/axis-studios/work.js @@ -0,0 +1,82 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const { type, tag } = ctx.params || ''; + const response = await got({ + method: 'get', + url: `https://axisstudiosgroup.com/${type}/${tag}`, + }); + const data = response.data; + const $ = cheerio.load(data); // 使用 cheerio 加载返回的 HTML + const list = $('a.overlay-link').get().slice(0, 13); + const articledata = await Promise.all( + list.map(async (item) => { + const link = `https://axisstudiosgroup.com${$(item) + .attr('href') + .replace(/https:/, '')}`; + + const cache = await ctx.cache.get(link); + if (cache) { + return Promise.resolve(JSON.parse(cache)); + } + + const response2 = await got({ + method: 'get', + url: link, + }); + + const articleHtml = response2.data; + const $2 = cheerio.load(articleHtml); + + $2('.slider-nav').remove(); // 图片导航 + $2('.social-wrapper').remove(); // 社交按钮 + $2('source').remove(); // 莫名其妙的图片 + $2('video').remove(); // 视频标签 + $2('button').remove(); // 按钮 + $2('div.modal.fade').remove(); // 莫名奇妙的图片 + $2('i').remove(); + + const youtube = $2('.mcdr.playlist-control a').attr('data-video-type') === 'video/youtube' ? $2('.mcdr.playlist-control a').attr('data-video-url').replace('https://www.youtube.com/watch?v=', '') : ''; + const mp4 = $2('.mcdr.playlist-control a').attr('data-video-type') === 'video/mp4' ? $2('.mcdr.playlist-control a').attr('data-video-url') : ''; + + const content = $2('.container-fluid>div:nth-child(2)') + .html() + .replace(//g, '') + .replace(//g, '') + .replace(/<.?div>/g, '') + .replace(//g, ''); + const single = { + describe: content, + title: $2('.overlay-content').find('h1').text(), + link: link, + mp4, + youtube, + }; + ctx.cache.set(link, JSON.stringify(single)); + return Promise.resolve(single); + }) + ); + + ctx.state.data = { + title: `Axis Studios | ${type} ${tag ? tag : ''}`, + link: 'http://axisstudiosgroup.com', + description: $('description').text(), + item: list.map((item, index) => { + let video = ''; + if (articledata[index].mp4) { + video = `
`; + } + if (articledata[index].youtube) { + video = `
`; + } + return { + title: `${articledata[index].title}`, + description: `${video}+${articledata[index].describe}`, + link: `${articledata[index].link}`, + }; + }), + }; +};