From e9124edbc409155c707dbf3835ed22383fa68010 Mon Sep 17 00:00:00 2001 From: Queensferry Date: Sun, 14 Feb 2021 02:22:45 +0800 Subject: [PATCH] feat: improve pornhub routes by introducing a `language` option (#6874) * feat: improve pornhub routes by introducing a `language` option * chore(docs): fix pornhub en docs --- docs/en/multimedia.md | 17 ++++++++++------- docs/multimedia.md | 21 ++++++++++++++------- lib/router.js | 8 ++++---- lib/routes/pornhub/category_url.js | 3 ++- lib/routes/pornhub/model.js | 5 +++-- lib/routes/pornhub/pornstar.js | 5 +++-- lib/routes/pornhub/users.js | 4 +++- 7 files changed, 39 insertions(+), 24 deletions(-) diff --git a/docs/en/multimedia.md b/docs/en/multimedia.md index 8e03ec5b2..79ef68b38 100644 --- a/docs/en/multimedia.md +++ b/docs/en/multimedia.md @@ -2,7 +2,7 @@ pageClass: routes --- -# Multimedia +# Multimedia ## 60-Second Science - Scientific American @@ -78,15 +78,15 @@ Official RSS: https://eztv.io/ezrss.xml ### Users - + ### Verified amateur / Model - + ### Verified model / Pornstar - + **`sort`** @@ -94,12 +94,15 @@ Official RSS: https://eztv.io/ezrss.xml | ----------- | ----------- | --------- | ------- | ------ | | Most Recent | Most Viewed | Top Rated | Longest | Newest | - - ### Video List - + +**`language`** + +Refer to [Pornhub F.A.Qs](https://help.pornhub.com/hc/en-us/articles/360044327034-How-do-I-change-the-language-), English by default. For example: +- `cn` (Chinese), for Pornhub in China ; +- `jp` (Japanese), for Pornhub in Japan etc. ## Sankaku Complex diff --git a/docs/multimedia.md b/docs/multimedia.md index 2fe3b5c7c..7b28d8eab 100644 --- a/docs/multimedia.md +++ b/docs/multimedia.md @@ -163,7 +163,7 @@ pageClass: routes ::: tip 提示 -栏目 ID 查找示例: +栏目 ID 查找示例: 打开栏目具体某一期页面,F12 控制台输入`column_id`得到栏目 ID。 ::: @@ -518,15 +518,15 @@ pageClass: routes ### 用户 - + -### 素人(Verified amateur /model) +### 素人(Verified amateur / Model) - + -### 色情明星(Verified model /pornstar) +### 色情明星(Verified model / Pornstar) - + **排序方式 `sort`** @@ -536,7 +536,14 @@ pageClass: routes ### 视频列表 - + + +**语言 `language`** + +参见 [Pornhub F.A.Qs](https://help.pornhub.com/hc/en-us/articles/360044327034-How-do-I-change-the-language-),放空则默认为英文。常见的有: + +- `cn`(中文),对应中文站 ; +- `jp`(日语),对应日语站 等。 ## Prestige 蚊香社 diff --git a/lib/router.js b/lib/router.js index f45228901..46e541c11 100644 --- a/lib/router.js +++ b/lib/router.js @@ -323,10 +323,10 @@ router.get('/konachan.net/post/popular_recent/:period', require('./routes/konach // PornHub 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')); +router.get('/pornhub/:language?/category_url/:url?', require('./routes/pornhub/category_url')); +router.get('/pornhub/:language?/users/:username', require('./routes/pornhub/users')); +router.get('/pornhub/:language?/model/:username/:sort?', require('./routes/pornhub/model')); +router.get('/pornhub/:language?/pornstar/:username/:sort?', require('./routes/pornhub/pornstar')); // Prestige router.get('/prestige-av/series/:mid/:sort?', require('./routes/prestige-av/series')); diff --git a/lib/routes/pornhub/category_url.js b/lib/routes/pornhub/category_url.js index 5fb6e79c9..12076ef19 100644 --- a/lib/routes/pornhub/category_url.js +++ b/lib/routes/pornhub/category_url.js @@ -2,8 +2,9 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); module.exports = async (ctx) => { + const language = ctx.params.language || 'www'; const url = ctx.params.url || 'video'; - const link = `https://www.pornhub.com/${url}`; + const link = `https://${language}.pornhub.com/${url}`; const response = await got.get(link); const $ = cheerio.load(response.data); diff --git a/lib/routes/pornhub/model.js b/lib/routes/pornhub/model.js index 6df7b1df8..188086d58 100644 --- a/lib/routes/pornhub/model.js +++ b/lib/routes/pornhub/model.js @@ -2,9 +2,10 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); module.exports = async (ctx) => { + const language = ctx.params.language || 'www'; const username = ctx.params.username; - const sort = ctx.params.sort ? ctx.params.sort : 'mr'; - const link = `https://www.pornhub.com/model/${username}/videos?o=${sort}`; + const sort = ctx.params.sort || 'mr'; + const link = `https://${language}.pornhub.com/model/${username}/videos?o=${sort}`; const response = await got.get(link); const $ = cheerio.load(response.data); diff --git a/lib/routes/pornhub/pornstar.js b/lib/routes/pornhub/pornstar.js index 543e859f7..e522755fa 100644 --- a/lib/routes/pornhub/pornstar.js +++ b/lib/routes/pornhub/pornstar.js @@ -2,9 +2,10 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); module.exports = async (ctx) => { + const language = ctx.params.language || 'www'; const username = ctx.params.username; - const sort = ctx.params.sort ? ctx.params.sort : 'mr'; - const link = `https://www.pornhub.com/pornstar/${username}/videos?o=${sort}`; + const sort = ctx.params.sort || 'mr'; + const link = `https://${language}.pornhub.com/pornstar/${username}/videos?o=${sort}`; const response = await got.get(link); const $ = cheerio.load(response.data); diff --git a/lib/routes/pornhub/users.js b/lib/routes/pornhub/users.js index 7351c6ede..f3f3423ea 100644 --- a/lib/routes/pornhub/users.js +++ b/lib/routes/pornhub/users.js @@ -2,8 +2,9 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); module.exports = async (ctx) => { + const language = ctx.params.language || 'www'; const username = ctx.params.username; - const link = `https://www.pornhub.com/users/${username}/videos`; + const link = `https://${language}.pornhub.com/users/${username}/videos`; const response = await got.get(link); const $ = cheerio.load(response.data); @@ -12,6 +13,7 @@ module.exports = async (ctx) => { ctx.state.data = { title: $('title').first().text(), link: link, + allowEmpty: true, item: list && list