/
index.ts
93 lines (83 loc) · 2.64 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import { Route } from '@/types';
import { getCurrentPath } from '@/utils/helpers';
const __dirname = getCurrentPath(import.meta.url);
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
import { art } from '@/utils/render';
import path from 'node:path';
import { domainValidation } from './utils';
export const route: Route = {
path: '/:lang?',
categories: ['multimedia'],
example: '/91porn',
parameters: { lang: 'Language, see below, `en_US` by default ' },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: true,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['91porn.com/index.php'],
target: '',
},
],
name: 'Hot Video Today',
maintainers: ['TonyRL'],
handler,
url: '91porn.com/index.php',
description: `| English | 简体中文 | 繁體中文 |
| ------- | -------- | -------- |
| en\_US | cn\_CN | zh\_ZH |`,
};
async function handler(ctx) {
const { domain = '91porn.com' } = ctx.req.query();
const siteUrl = `https://${domain}/index.php`;
const { lang = 'en_US' } = ctx.req.param();
domainValidation(domain);
const response = await got.post(siteUrl, {
form: {
session_language: lang,
},
headers: {
referer: siteUrl,
},
});
const $ = 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) =>
cache.tryGet(`91porn:${lang}:${new URL(item.link).searchParams.get('viewkey')}`, async () => {
const { data } = await got(item.link);
const $ = 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;
})
)
);
return {
title: `${$('.login_register_header').text()} - 91porn`,
link: siteUrl,
item: items,
};
}