From 8978feb645bdecfdbe75a477394ed1ff3b42ba0a Mon Sep 17 00:00:00 2001 From: Tony Date: Wed, 3 Aug 2022 06:05:26 +0800 Subject: [PATCH] feat(route): 91porn author (#10381) --- docs/en/multimedia.md | 4 +++ docs/multimedia.md | 4 +++ lib/v2/91porn/author.js | 58 +++++++++++++++++++++++++++++++++++++ lib/v2/91porn/maintainer.js | 1 + lib/v2/91porn/radar.js | 8 ++++- lib/v2/91porn/router.js | 1 + 6 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 lib/v2/91porn/author.js diff --git a/docs/en/multimedia.md b/docs/en/multimedia.md index 670d014fb..7005452a3 100644 --- a/docs/en/multimedia.md +++ b/docs/en/multimedia.md @@ -101,6 +101,10 @@ When `uncensored_makersr` as **Uncensored** is chosen as **Category**, the avail +### Author + + + ## 99% Invisible ### Transcript diff --git a/docs/multimedia.md b/docs/multimedia.md index 95a22b07e..d197e9045 100644 --- a/docs/multimedia.md +++ b/docs/multimedia.md @@ -241,6 +241,10 @@ pageClass: routes +### 作者 + + + ## 99% Invisible ### Transcript diff --git a/lib/v2/91porn/author.js b/lib/v2/91porn/author.js new file mode 100644 index 000000000..3586214d7 --- /dev/null +++ b/lib/v2/91porn/author.js @@ -0,0 +1,58 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); +const { art } = require('@/utils/render'); +const path = require('path'); + +module.exports = async (ctx) => { + const { domain = '91porn.com' } = ctx.query; + const { uid, lang = 'en_US' } = ctx.params; + const siteUrl = `https://${domain}/uvideos.php?UID=${uid}&type=public`; + + const response = await got.post(siteUrl, { + form: { + session_language: lang, + }, + headers: { + referer: siteUrl, + }, + }); + + const $ = cheerio.load(response.data); + + let items = $('.row .well') + .toArray() + .map((item) => { + item = $(item); + return { + title: item.find('.video-title').text(), + link: item.find('a').attr('href'), + poster: item.find('.img-responsive').attr('src'), + }; + }); + + items = await Promise.all( + items.map((item) => + ctx.cache.tryGet(`91porn:${lang}:${new URL(item.link).searchParams.get('viewkey')}`, async () => { + const { data } = await got(item.link); + const $ = cheerio.load(data); + + item.pubDate = parseDate($('.title-yakov').eq(0).text(), 'YYYY-MM-DD'); + item.description = art(path.join(__dirname, 'templates/index.art'), { + link: item.link, + poster: item.poster, + }); + item.author = $('.title-yakov a span').text(); + delete item.poster; + + return item; + }) + ) + ); + + ctx.state.data = { + title: `${$('.login_register_header').text()} - 91porn`, + link: siteUrl, + item: items, + }; +}; diff --git a/lib/v2/91porn/maintainer.js b/lib/v2/91porn/maintainer.js index c45323d6a..3257fff98 100644 --- a/lib/v2/91porn/maintainer.js +++ b/lib/v2/91porn/maintainer.js @@ -1,3 +1,4 @@ module.exports = { + '/author/:uid/:lang?': ['TonyRL'], '/:lang?': ['TonyRL'], }; diff --git a/lib/v2/91porn/radar.js b/lib/v2/91porn/radar.js index aeac305ff..87d08c940 100644 --- a/lib/v2/91porn/radar.js +++ b/lib/v2/91porn/radar.js @@ -3,11 +3,17 @@ module.exports = { _name: '91porn', '.': [ { - title: '91porn', + title: '今日排行', docs: 'https://docs.rsshub.app/multimedia.html#_91porn', source: ['/index.php'], target: '/91porn', }, + { + title: '作者', + docs: 'https://docs.rsshub.app/multimedia.html#_91porn', + source: ['/uvideos.php'], + target: (_params, url) => `/91porn/author/${new URL(url).searchParams.get('UID')}`, + }, ], }, }; diff --git a/lib/v2/91porn/router.js b/lib/v2/91porn/router.js index 7df06e073..3c8782564 100644 --- a/lib/v2/91porn/router.js +++ b/lib/v2/91porn/router.js @@ -1,3 +1,4 @@ module.exports = (router) => { + router.get('/author/:uid/:lang?', require('./author')); router.get('/:lang?', require('./index')); };