Files
RSSHub/lib/routes/javtrailers/casts.ts
T
DIYgod 566f028aaf refactor: migrate browser automation to Playwright (#21901)
* refactor: migrate browser automation to Playwright

* ci: update browser checks for Playwright
2026-05-04 21:16:18 +08:00

47 lines
1.4 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 type { Route } from '@/types';
import cache from '@/utils/cache';
import playwright from '@/utils/playwright';
import { baseUrl, getItem, parseList, playwrightFetch } 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,
features: {
nsfw: true,
requirePuppeteer: true,
},
};
async function handler(ctx) {
const { cast } = ctx.req.param();
const browser = await playwright();
const response = await playwrightFetch(`${baseUrl}/api/casts/${cast}?page=0`, browser);
const list = parseList(response.videos);
const items = await Promise.all(list.map((item) => cache.tryGet(item.link, () => getItem(item, browser))));
await browser.close();
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,
};
}