diff --git a/docs/anime.md b/docs/anime.md index 8472823fed..e39f3f40f8 100644 --- a/docs/anime.md +++ b/docs/anime.md @@ -739,11 +739,15 @@ Sources ### 最新 - + ### 分类更新 - + + +### 標籤更新 + + ## 鼠绘漫画 diff --git a/lib/router.js b/lib/router.js index d08a20e8a2..616c2d9f4d 100644 --- a/lib/router.js +++ b/lib/router.js @@ -2603,8 +2603,8 @@ router.get('/weexcn/news/:typeid', lazyloadRouteHandler('./routes/weexcn/index') // router.get('/eastmoney/ttjj/user/:uid', lazyloadRouteHandler('./routes/eastmoney/ttjj/user')); // 紳士漫畫 -router.get('/ssmh', lazyloadRouteHandler('./routes/ssmh')); -router.get('/ssmh/category/:cid', lazyloadRouteHandler('./routes/ssmh/category')); +// router.get('/ssmh', lazyloadRouteHandler('./routes/ssmh')); +// router.get('/ssmh/category/:cid', lazyloadRouteHandler('./routes/ssmh/category')); // 华南师范大学研究生学院 router.get('/scnuyjs', lazyloadRouteHandler('./routes/universities/scnu/scnuyjs')); diff --git a/lib/routes/ssmh/category.js b/lib/routes/ssmh/category.js deleted file mode 100644 index c1f209b3f9..0000000000 --- a/lib/routes/ssmh/category.js +++ /dev/null @@ -1,50 +0,0 @@ -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('src') ? item.find('a > img').attr('src') : 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(), - }; -}; diff --git a/lib/routes/ssmh/index.js b/lib/routes/ssmh/index.js deleted file mode 100644 index ec6c600ebd..0000000000 --- a/lib/routes/ssmh/index.js +++ /dev/null @@ -1,32 +0,0 @@ -const got = require('@/utils/got'); -const cheerio = require('cheerio'); - -module.exports = async (ctx) => { - const response = await got({ - method: 'get', - url: 'https://wnacg.org/albums.html', - }); - - const data = response.data; - - const $ = cheerio.load(data); - const list = $('.pic_box'); - let thumbnail_url; - let link_url; - ctx.state.data = { - title: '紳士漫畫', - link: 'https://wnacg.org/albums.html', - item: list - .map((index, item) => { - item = $(item); - thumbnail_url = `https:${item.find('a > img').attr('src') ?? item.find('a > img').attr('data-original')}`; - link_url = `https://wnacg.org${item.find('a').attr('href')}`; - return { - title: item.find('a').attr('title'), - description: ``, - link: link_url, - }; - }) - .get(), - }; -}; diff --git a/lib/v2/wnacg/index.js b/lib/v2/wnacg/index.js new file mode 100644 index 0000000000..425e308289 --- /dev/null +++ b/lib/v2/wnacg/index.js @@ -0,0 +1,110 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); +const { art } = require('@/utils/render'); +const path = require('path'); + +const categories = { + 1: '同人誌 漢化', + 2: '同人誌 CG畫集', + 3: '同人誌 Cosplay', + 5: '同人誌', + 6: '單行本', + 7: '雜誌&短篇', + 9: '單行本 漢化', + 10: '雜誌&短篇 漢化', + 12: '同人誌 日語', + 13: '單行本 日語', + 14: '雜誌&短篇 日語', + 16: '同人誌 English', + 17: '單行本 English', + 19: '韓漫', + 20: '韓漫 漢化', + 21: '韓漫 生肉', +}; + +const baseUrl = 'https://wnacg.org'; + +module.exports = async (ctx) => { + const { cid, tag } = ctx.params; + if (cid && !Object.keys(categories).includes(cid)) { + throw Error('此分类不存在'); + } + + const url = `${baseUrl}/albums${cid ? `-index-cate-${cid}` : ''}${tag ? `-index-tag-${tag}` : ''}.html`; + const { data } = await got(url); + const $ = cheerio.load(data); + + const list = $('.gallary_item') + .toArray() + .map((item) => { + item = $(item); + const href = item.find('a').attr('href'); + const aid = href.match(/^\/photos-index-aid-(\d+)\.html$/)[1]; + return { + title: item.find('a').attr('title'), + link: `${baseUrl}${href}`, + pubDate: parseDate( + item + .find('.info_col') + .text() + .replace(/\d+張照片,\n創建於/, ''), + 'YYYY-MM-DD' + ), + aid, + }; + }); + + const items = await Promise.all( + list.map((item) => + ctx.cache.tryGet(item.link, async () => { + const { data: descRes } = await got(item.link, { + headers: { + referer: encodeURI(url), + }, + }); + let $ = cheerio.load(descRes); + const author = $('.uwuinfo p').first().text(); + const category = $('.tagshow') + .toArray() + .map((item) => $(item).text()); + $('.addtags').remove(); + const description = $('.uwconn').html(); + + const { data } = await got(`${baseUrl}/photos-gallery-aid-${item.aid}.html`, { + headers: { + referer: `${baseUrl}/photos-slide-aid-${item.aid}.html`, + }, + }); + $ = cheerio.load(data); + + const imgListMatch = $('script') + .text() + .match(/var imglist = (\[.*\]);"\);/)[1]; + + const imgList = JSON.parse( + imgListMatch + .replace(/url:/g, '"url":') + .replace(/caption:/g, '"caption":') + .replace(/fast_img_host\+\\/g, '') + .replace(/\\/g, '') + ); + + item.author = author; + item.category = category; + item.description = art(path.join(__dirname, 'templates/manga.art'), { + description, + imgList, + }); + + return item; + }) + ) + ); + + ctx.state.data = { + title: $('head title').text(), + link: url, + item: items, + }; +}; diff --git a/lib/v2/wnacg/maintainer.js b/lib/v2/wnacg/maintainer.js new file mode 100644 index 0000000000..5eb05661c8 --- /dev/null +++ b/lib/v2/wnacg/maintainer.js @@ -0,0 +1,5 @@ +module.exports = { + '/': ['KenMizz'], + '/category/:cid': ['Gandum2077'], + '/tag/:tag': ['Gandum2077'], +}; diff --git a/lib/v2/wnacg/radar.js b/lib/v2/wnacg/radar.js new file mode 100644 index 0000000000..42f6a54ba6 --- /dev/null +++ b/lib/v2/wnacg/radar.js @@ -0,0 +1,25 @@ +module.exports = { + 'wnacg.org': { + _name: '紳士漫畫', + '.': [ + { + title: '最新', + docs: 'https://docs.rsshub.app/anime.html#shen-shi-man-hua', + source: ['/albums.html', '/'], + target: '/wnacg', + }, + { + title: '分类更新', + docs: 'https://docs.rsshub.app/anime.html#shen-shi-man-hua', + source: ['/*'], + target: (_, url) => `/wnacg/category/${new URL(url).pathname.match(/albums-index-cate-(\d+)\.html$/)[1]}`, + }, + { + title: '標籤更新', + docs: 'https://docs.rsshub.app/anime.html#shen-shi-man-hua', + source: ['/*'], + target: (_, url) => `/wnacg/tag/${new URL(url).pathname.match(/albums-index-tag-(.+?)\.html$/)[1]}`, + }, + ], + }, +}; diff --git a/lib/v2/wnacg/router.js b/lib/v2/wnacg/router.js new file mode 100644 index 0000000000..4e310405e5 --- /dev/null +++ b/lib/v2/wnacg/router.js @@ -0,0 +1,5 @@ +module.exports = (router) => { + router.get('/', require('./index')); + router.get('/category/:cid', require('./index')); + router.get('/tag/:tag', require('./index')); +}; diff --git a/lib/v2/wnacg/templates/manga.art b/lib/v2/wnacg/templates/manga.art new file mode 100644 index 0000000000..a812bb0925 --- /dev/null +++ b/lib/v2/wnacg/templates/manga.art @@ -0,0 +1,9 @@ +{{ if description }} +{{@ description }} +{{ /if }} +
+{{ if imgList }} +{{ each imgList img }} +{{ img.caption }} +{{ /each }} +{{ /if }}