Files
RSSHub/lib/routes/javtrailers/casts.ts
T
Tony b857abcf42 feat(route): javtrailers (#17590)
* feat(route): javtrailers

* feat(casts): enhance description with castWiki data
2024-11-15 18:13:49 +08:00

42 lines
1.3 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { Route } from '@/types';
import ofetch from '@/utils/ofetch';
import cache from '@/utils/cache';
import { baseUrl, getItem, headers, parseList } from './utils';
export const route: Route = {
path: '/casts/:cast',
categories: ['multimedia'],
example: '/javtrailers/casts/hibiki-otsuki',
parameters: { cast: 'Cast name, can be found in the URL of the cast page' },
radar: [
{
source: ['javtrailers.com/casts/:category'],
},
],
name: 'Casts',
maintainers: ['TonyRL'],
url: 'javtrailers.com/casts',
handler,
};
async function handler(ctx) {
const { cast } = ctx.req.param();
const response = await ofetch(`${baseUrl}/api/casts/${cast}?page=0`, {
headers,
});
const list = parseList(response.videos);
const items = await Promise.all(list.map((item) => cache.tryGet(item.link, () => getItem(item))));
return {
title: `Watch ${response.cast.name} Jav Online | Japanese Adult Video - JavTrailers.com`,
description: response.cast.castWiki?.description.replaceAll('\n', ' ') ?? `Watch ${response.cast.name} Jav video’s free, we have the largest Jav collections with high definition`,
image: response.cast.avatar,
link: `${baseUrl}/casts/${cast}`,
item: items,
};
}