diff --git a/docs/anime.md b/docs/anime.md index cc18fb87f..bcc037374 100644 --- a/docs/anime.md +++ b/docs/anime.md @@ -332,6 +332,10 @@ pageClass: routes +### 分类更新 + + + ## 鼠绘漫画 ### 鼠绘漫画 diff --git a/lib/router.js b/lib/router.js index fd5c5ea0e..d36704c2e 100644 --- a/lib/router.js +++ b/lib/router.js @@ -2717,6 +2717,7 @@ router.get('/eastmoney/user/:uid', require('./routes/eastmoney/user')); // 紳士漫畫 router.get('/ssmh', require('./routes/ssmh')); +router.get('/ssmh/category/:cid', require('./routes/ssmh/category')); // 武昌首义学院 router.get('/wsyu/news/:type?', require('./routes/universities/wsyu/news')); diff --git a/lib/routes/ssmh/category.js b/lib/routes/ssmh/category.js new file mode 100644 index 000000000..a10983092 --- /dev/null +++ b/lib/routes/ssmh/category.js @@ -0,0 +1,50 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +const categories = { + 1: '同人誌 漢化', + 2: '同人誌 CG畫集', + 3: '同人誌 Cosplay', + 5: '同人誌', + 6: '單行本', + 7: '雜誌&短篇', + 9: '單行本 漢化', + 10: '雜誌&短篇 漢化', + 12: '同人誌 日語', + 13: '單行本 日語', + 14: '雜誌&短篇 日語', +}; + +module.exports = async (ctx) => { + const cid = ctx.params.cid; + if (!cid || !Object.keys(categories).includes(cid)) { + ctx.state.data = { + title: '此分类不存在', + }; + return; + } + const url = `https://www.wnacg.com/albums-index-cate-${cid}.html`; + const response = await got.get(url); + + const data = response.data; + + const $ = cheerio.load(data); + const list = $('.pic_box'); + + ctx.state.data = { + title: '紳士漫畫 - ' + categories[cid], + link: url, + item: list + .map((index, item) => { + item = $(item); + const thumbnail_url = 'https:' + `${item.find('a > img').attr('data-original')}`; + const link_url = 'https://wnacg.org' + `${item.find('a').attr('href')}`; + return { + title: item.find('a').attr('title'), + description: ``, + link: link_url, + }; + }) + .get(), + }; +};