From 3532000fbd5a9fb3bd964106feab786e56d33809 Mon Sep 17 00:00:00 2001 From: I2IMk <66695371+I2IMk@users.noreply.github.com> Date: Mon, 14 Sep 2020 23:43:46 +0800 Subject: [PATCH] feat: add pornhub users (#5655) --- docs/en/multimedia.md | 4 ++++ docs/multimedia.md | 4 ++++ lib/router.js | 1 + lib/routes/pornhub/users.js | 29 +++++++++++++++++++++++++++++ 4 files changed, 38 insertions(+) create mode 100644 lib/routes/pornhub/users.js diff --git a/docs/en/multimedia.md b/docs/en/multimedia.md index c2304c013..4430883ca 100644 --- a/docs/en/multimedia.md +++ b/docs/en/multimedia.md @@ -76,6 +76,10 @@ Official RSS: https://eztv.io/ezrss.xml +### Users + + + ### Verified amateur / Model diff --git a/docs/multimedia.md b/docs/multimedia.md index 9bb9cbf04..50cb939d5 100644 --- a/docs/multimedia.md +++ b/docs/multimedia.md @@ -279,6 +279,10 @@ pageClass: routes +### 用户 + + + ### 素人(Verified amateur /model) diff --git a/lib/router.js b/lib/router.js index cd9a06d2e..3eea3fc1d 100644 --- a/lib/router.js +++ b/lib/router.js @@ -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')); diff --git a/lib/routes/pornhub/users.js b/lib/routes/pornhub/users.js new file mode 100644 index 000000000..7351c6ede --- /dev/null +++ b/lib/routes/pornhub/users.js @@ -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: ``, + }; + }) + .get(), + }; +};