feat: add pornhub users (#5655)

This commit is contained in:
I2IMk 2020-09-14 23:43:46 +08:00 committed by GitHub
parent 2d03b4d433
commit 3532000fbd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 38 additions and 0 deletions

View File

@ -76,6 +76,10 @@ Official RSS: https://eztv.io/ezrss.xml
<RouteEn author="nczitzk" example="/pornhub/search/stepsister" path="/pornhub/search/:keyword" :paramsDesc="['keyword']"/>
### Users
<RouteEn author="I2IMk" example="/pornhub/users/0maru0" path="/pornhub/users/:username" :paramsDesc="['username, part of the url e.g. `pornhub.com/users/0maru0`']" />
### Verified amateur / Model
<RouteEn author="I2IMk" example="/pornhub/model/stacy-starando" path="/pornhub/model/:username/:sort?" :paramsDesc="['username, part of the url e.g. `pornhub.com/model/stacy-starando`', 'sorting method, see below']" />

View File

@ -279,6 +279,10 @@ pageClass: routes
<Route author="nczitzk" example="/pornhub/search/stepsister" path="/pornhub/search/:keyword" :paramsDesc="['关键字']"/>
### 用户
<Route author="I2IMk" example="/pornhub/users/0maru0" path="/pornhub/users/:username" :paramsDesc="['用户名, 对应其专页地址的后面部分, 如 `pornhub.com/users/0maru0`']" />
### 素人Verified amateur /model
<Route author="I2IMk" example="/pornhub/model/stacy-starando" path="/pornhub/model/:username/:sort?" :paramsDesc="['用户名, 对应其专页地址的后面部分, 如 `pornhub.com/model/stacy-starando`', '排序方式, 下文会提到']" />

View File

@ -306,6 +306,7 @@ router.get('/konachan.net/post/popular_recent/:period', require('./routes/konach
router.get('/pornhub/category/:caty', require('./routes/pornhub/category'));
router.get('/pornhub/search/:keyword', require('./routes/pornhub/search'));
router.get('/pornhub/category_url/:url?', require('./routes/pornhub/category_url'));
router.get('/pornhub/users/:username', require('./routes/pornhub/users'));
router.get('/pornhub/model/:username/:sort?', require('./routes/pornhub/model'));
router.get('/pornhub/pornstar/:username/:sort?', require('./routes/pornhub/pornstar'));

View File

@ -0,0 +1,29 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const username = ctx.params.username;
const link = `https://www.pornhub.com/users/${username}/videos`;
const response = await got.get(link);
const $ = cheerio.load(response.data);
const list = $('.videoUList .videoBox');
ctx.state.data = {
title: $('title').first().text(),
link: link,
item:
list &&
list
.map((_, e) => {
e = $(e);
return {
title: e.find('span.title a').text(),
link: `https://www.pornhub.com` + e.find('span.title a').attr('href'),
description: `<img src="${e.find('img.thumb').attr('data-thumb_url')}">`,
};
})
.get(),
};
};