feat(route): 91porn author (#10381)

This commit is contained in:
Tony 2022-08-03 06:05:26 +08:00 committed by GitHub
parent bc261417fb
commit 8978feb645
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 75 additions and 1 deletions

View File

@ -101,6 +101,10 @@ When `uncensored_makersr` as **Uncensored** is chosen as **Category**, the avail
</RouteEn>
### Author
<RouteEn author="TonyRL" example="/91porn/author/2d6d2iWm4vVCwqujAZbSrKt2QJCbbaObv9HQ21Zo8wGJWudWBg" path="/91porn/author/:uid/:lang?" :paramsDesc="['Author ID, can be found in URL', 'Language, see above, `en_US` by default ']" radar="1" rssbud="1" anticrawler="1" />
## 99% Invisible
### Transcript

View File

@ -241,6 +241,10 @@ pageClass: routes
</Route>
### 作者
<Route author="TonyRL" example="/91porn/author/2d6d2iWm4vVCwqujAZbSrKt2QJCbbaObv9HQ21Zo8wGJWudWBg" path="/91porn/author/:uid/:lang?" :paramsDesc="['作者 ID可在 URL 中找到', '语言,见上表,默认 `en_US`']" radar="1" rssbud="1" anticrawler="1" />
## 99% Invisible
### Transcript

58
lib/v2/91porn/author.js Normal file
View File

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

View File

@ -1,3 +1,4 @@
module.exports = {
'/author/:uid/:lang?': ['TonyRL'],
'/:lang?': ['TonyRL'],
};

View File

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

View File

@ -1,3 +1,4 @@
module.exports = (router) => {
router.get('/author/:uid/:lang?', require('./author'));
router.get('/:lang?', require('./index'));
};