feat: add 紳士漫畫 分类更新 (#6120)
This commit is contained in:
parent
b6d4b08aac
commit
517d29da2c
|
|
@ -332,6 +332,10 @@ pageClass: routes
|
|||
|
||||
<Route author="KenMizz" example="/ssmh" path="/ssmh/" />
|
||||
|
||||
### 分类更新
|
||||
|
||||
<Route author="Gandum2077" example="/ssmh/category/6" path="/ssmh/category/:cid" :paramsDesc="['分类的id,即对应 URL 中的数字']" />
|
||||
|
||||
## 鼠绘漫画
|
||||
|
||||
### 鼠绘漫画
|
||||
|
|
|
|||
|
|
@ -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'));
|
||||
|
|
|
|||
|
|
@ -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: `<img src=${thumbnail_url} referrerpolicy="no-referrer">`,
|
||||
link: link_url,
|
||||
};
|
||||
})
|
||||
.get(),
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue