feat(route): add route of javtiful (#16964)

* feat(route): add route of javtiful

* fix: fix some wrong
This commit is contained in:
huanfei 2024-09-30 23:50:24 +08:00 committed by GitHub
parent 6bd881cecc
commit 8ec9235344
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 105 additions and 0 deletions

View File

@ -0,0 +1,37 @@
import { Route, Data, DataItem } from '@/types';
import ofetch from '@/utils/ofetch';
import { load } from 'cheerio';
import { parseItems } from './utils';
export const route: Route = {
path: '/actress/:id',
name: 'Actress',
maintainers: ['huanfe1'],
example: '/javtiful/actress/akari-tsumugi',
parameters: { id: 'Actress name' },
handler,
categories: ['multimedia'],
radar: [
{
source: ['javtiful.com/actress/:id', 'javtiful.com/actress/:id/*'],
target: '/actress/:id',
},
],
};
async function handler(ctx): Promise<Data> {
const { id } = ctx.req.param();
const html = await ofetch(`https://javtiful.com/actress/${id}`);
const $ = load(<string>html);
const items: DataItem[] = $('section .card:not(:has(.bg-danger))')
.toArray()
.map((item) => parseItems($(item)));
return {
title: $('.channel-item__name_details a').text(),
link: `https://javtiful.com/actress/${id}`,
allowEmpty: true,
item: items,
image: $('.content-section-title img').attr('src'),
language: $('html').attr('lang'),
};
}

View File

@ -0,0 +1,37 @@
import { Route, Data, DataItem } from '@/types';
import ofetch from '@/utils/ofetch';
import { load } from 'cheerio';
import { parseItems } from './utils';
export const route: Route = {
path: '/channel/:id',
name: 'Channel',
maintainers: ['huanfe1'],
example: '/javtiful/channel/madonna',
parameters: { id: 'Channel name' },
handler,
categories: ['multimedia'],
radar: [
{
source: ['javtiful.com/channel/:id', 'javtiful.com/channel/:id/*'],
target: '/channel/:id',
},
],
};
async function handler(ctx): Promise<Data> {
const { id } = ctx.req.param();
const html = await ofetch(`https://javtiful.com/channel/${id}`);
const $ = load(<string>html);
const items: DataItem[] = $('section .card:not(:has(.bg-danger))')
.toArray()
.map((item) => parseItems($(item)));
return {
title: $('.channel-item__name_details a').text(),
link: `https://javtiful.com/channel/${id}`,
allowEmpty: true,
item: items,
image: $('.content-section-title img').attr('src'),
language: $('html').attr('lang'),
};
}

View File

@ -0,0 +1,6 @@
import type { Namespace } from '@/types';
export const namespace: Namespace = {
name: 'Javtiful',
url: 'javtiful.com',
};

View File

@ -0,0 +1,7 @@
{{ if previewVideo }}
<video controls preload="metadata" poster="{{ poster }}">
<source src="{{ previewVideo }}" type="video/mp4">
</video>
{{else if poster}}
<img src="{{ poster }}">
{{ /if }}

View File

@ -0,0 +1,18 @@
import { getCurrentPath } from '@/utils/helpers';
const __dirname = getCurrentPath(import.meta.url);
import { art } from '@/utils/render';
import path from 'node:path';
import { parseRelativeDate } from '@/utils/parse-date';
const renderDescription = (data) => art(path.join(__dirname, 'templates/description.art'), data);
export const parseItems = (e) => ({
title: e.find('a > img').attr('alt')!,
link: e.find('a').attr('href')!,
description: renderDescription({
poster: e.find('a > img').data('src'),
previewVideo: e.find('a > span').data('trailer'),
}),
pubDate: parseRelativeDate(e.find('.video-addtime').text()),
});