diff --git a/docs/README.md b/docs/README.md index fbab3d45b..7f2e54f53 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1007,7 +1007,9 @@ GitHub 官方也提供了一些 RSS: ### Tits Guru - + + + ### nHentai diff --git a/router.js b/router.js index e47a8b049..a3bed7d79 100644 --- a/router.js +++ b/router.js @@ -801,6 +801,8 @@ router.get('/manhuagui/comic/:id', require('./routes/manhuagui/comic')); // Tits Guru router.get('/tits-guru/home', require('./routes/titsguru/home')); router.get('/tits-guru/daily', require('./routes/titsguru/daily')); +router.get('/tits-guru/category/:type', require('./routes/titsguru/category')); +router.get('/tits-guru/model/:name', require('./routes/titsguru/model')); // typora router.get('/typora/changelog', require('./routes/typora/changelog')); diff --git a/routes/titsguru/category.js b/routes/titsguru/category.js new file mode 100644 index 000000000..ce9a79b2c --- /dev/null +++ b/routes/titsguru/category.js @@ -0,0 +1,7 @@ +const { getPage, normalizeKeyword } = require('./util'); + +module.exports = async (ctx) => { + const { type } = ctx.params; + + ctx.state.data = await getPage(`https://tits-guru.com/category/${normalizeKeyword(type)}/date`); +}; diff --git a/routes/titsguru/daily.js b/routes/titsguru/daily.js index 8f29346a4..a4674d53c 100644 --- a/routes/titsguru/daily.js +++ b/routes/titsguru/daily.js @@ -1,21 +1,3 @@ -const cheerio = require('cheerio'); -const axios = require('../../utils/axios'); -const { mapDetail } = require('./util'); +const { createHandler } = require('./util'); -module.exports = async (ctx) => { - const { data } = await axios.get('https://tits-guru.com/thebest/perDay', { - headers: { Accept: '' }, - }); - const $ = cheerio.load(data); - - const items = $('.post-row') - .map((_, ele) => mapDetail($(ele))) - .toArray(); - - ctx.state.data = { - title: 'TitsGuru - Babe of The Day', - link: 'https://tits-guru.com/thebest/perDay', - description: 'TitsGuru - Babe of The Day', - item: items, - }; -}; +module.exports = createHandler('https://tits-guru.com/thebest/perDay'); diff --git a/routes/titsguru/home.js b/routes/titsguru/home.js index 778504fa5..a81cd82c4 100644 --- a/routes/titsguru/home.js +++ b/routes/titsguru/home.js @@ -1,21 +1,3 @@ -const cheerio = require('cheerio'); -const axios = require('../../utils/axios'); -const { mapDetail } = require('./util'); +const { createHandler } = require('./util'); -module.exports = async (ctx) => { - const { data } = await axios.get('https://tits-guru.com', { - headers: { Accept: '' }, - }); - const $ = cheerio.load(data); - - const items = $('.post-row') - .map((_, ele) => mapDetail($(ele))) - .toArray(); - - ctx.state.data = { - title: 'TitsGuru', - link: 'https://tits-guru.com/', - description: 'TitsGuru', - item: items, - }; -}; +module.exports = createHandler('https://tits-guru.com/'); diff --git a/routes/titsguru/model.js b/routes/titsguru/model.js new file mode 100644 index 000000000..77b96053d --- /dev/null +++ b/routes/titsguru/model.js @@ -0,0 +1,16 @@ +const { getPage, normalizeKeyword } = require('./util'); + +module.exports = async (ctx) => { + const { name } = ctx.params; + + const formalName = normalizeKeyword(name) + .split('-') + .map((word) => `${word[0].toUpperCase()}${word.substr(1)}`) + .join(' '); + + ctx.state.data = { + ...(await getPage(`https://tits-guru.com/boobs-model/${normalizeKeyword(name)}/date`)), + title: `TitsGuru - ${formalName}`, + description: `TitsGuru - ${formalName}`, + }; +}; diff --git a/routes/titsguru/util.js b/routes/titsguru/util.js index 730b111e4..03b8cedfc 100644 --- a/routes/titsguru/util.js +++ b/routes/titsguru/util.js @@ -1,6 +1,32 @@ const { resolve } = require('url'); +const cheerio = require('cheerio'); +const axios = require('../../utils/axios'); const day = require('dayjs'); +exports.getPage = async (url) => { + const { data } = await axios.get(url, { + headers: { Accept: '' }, + }); + const $ = cheerio.load(data); + + const title = $('.header-wrapper > h1').text(); + + const items = $('.post-row') + .map((_, ele) => exports.mapDetail($(ele))) + .toArray(); + + return { + title: `TitsGuru - ${title}`, + link: url, + description: `TitsGuru - ${title}`, + item: items, + }; +}; + +exports.createHandler = (url) => async (ctx) => { + ctx.state.data = await exports.getPage(url); +}; + exports.mapDetail = (ele) => { const link = resolve('https://tits-guru.com', ele.find('.img-link').attr('href')); const title = ele.find('.img-link > img').attr('title'); @@ -40,3 +66,5 @@ exports.parseDate = (str) => { } return new Date(`${dayStr} ${timeStr} UTC`); }; + +exports.normalizeKeyword = (keyword) => keyword.toLowerCase().replace(/[^\da-z]/g, '-');