t-guru: added support for models & categories (#1158)

This commit is contained in:
Zhu Chu 2018-11-16 18:51:45 +08:00 committed by DIYgod
parent 05d30fd5d2
commit a2e8220008
7 changed files with 60 additions and 41 deletions

View File

@ -1007,7 +1007,9 @@ GitHub 官方也提供了一些 RSS:
### Tits Guru
<route name="Home" author="MegrezZhu" example="/tits-guru/home" path="/tits-guru/home"/>
<route name="Babe of The Day" author="MegrezZhu" example="/tits-guru/daily" path="/tits-guru/daily"/>
<route name="Daily Best" author="MegrezZhu" example="/tits-guru/daily" path="/tits-guru/daily"/>
<route name="Models" author="MegrezZhu" example="/tits-guru/model/mila-azul" path="/tits-guru/model/:name" :paramsDesc="['指定模特名字,详见[这里](https://tits-guru.com/models)']"/>
<route name="Categories" author="MegrezZhu" example="/tits-guru/category/bikini" path="/tits-guru/category/:type" :paramsDesc="['指定类别,详见[这里](https://tits-guru.com/categories)']"/>
### nHentai

View File

@ -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'));

View File

@ -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`);
};

View File

@ -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');

View File

@ -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/');

16
routes/titsguru/model.js Normal file
View File

@ -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}`,
};
};

View File

@ -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, '-');