feat(route): add route of javtiful (#16964)
* feat(route): add route of javtiful * fix: fix some wrong
This commit is contained in:
parent
6bd881cecc
commit
8ec9235344
|
|
@ -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'),
|
||||
};
|
||||
}
|
||||
|
|
@ -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'),
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
import type { Namespace } from '@/types';
|
||||
|
||||
export const namespace: Namespace = {
|
||||
name: 'Javtiful',
|
||||
url: 'javtiful.com',
|
||||
};
|
||||
|
|
@ -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 }}
|
||||
|
|
@ -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()),
|
||||
});
|
||||
Loading…
Reference in New Issue