* refactor: use patchwright * refactor: migrate setRequestInterception and waitUntil * fix: overwrite ua * refactor: drop puppeteer cookie/requestfinished shims Migrate page.cookies/setCookie and browser.cookies/setCookie call sites to the native context APIs (page.context().cookies/addCookies), rewrite requestfinished handlers to await request.response() instead of consuming the synchronous puppeteer-shaped payload, and remove the now-redundant browser.close context-cleanup wrapper. Playwright already handles all of these natively; the shims existed only for the puppeteer -> playwright migration. * refactor: remove page.authenticate, page.setUserAgent, browser.newPage(), browser.userAgent() shims update cookie utility tests * refactor: replace browser instance with context in Playwright usage across multiple routes - Updated all instances of `browser` to `context` in Playwright-related functions for consistency and improved resource management. - Ensured proper closure of context after operations to prevent memory leaks. - Adjusted request interception methods to utilize the new context variable. * fix: direct type import * refactor: remove Puppeteer compatibility layers and unify page handling with Playwright * fix: test case * chore: bump patchright to v1.60.0 * chore: pin patchright to 1.59.1 nft can't resolve browser.json due to https://github.com/microsoft/playwright/pull/40093 * chore: pin to node 24.15 for playwright browser install on node 24.16 stucks due to https://github.com/microsoft/playwright/issues/40724 * fix: update patchright and patchright-core to version 1.60.2 and adjust minify-docker.js for compatibility * fix: import BrowserContext from patchright
45 lines
1.4 KiB
TypeScript
45 lines
1.4 KiB
TypeScript
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: '/studios/:studio',
|
|
categories: ['multimedia'],
|
|
example: '/javtrailers/studios/s1-no-1-style',
|
|
parameters: { studio: 'Studio name, can be found in the URL of the studio page' },
|
|
radar: [
|
|
{
|
|
source: ['javtrailers.com/studios/:category'],
|
|
},
|
|
],
|
|
name: 'Studios',
|
|
maintainers: ['TonyRL'],
|
|
handler,
|
|
features: {
|
|
nsfw: true,
|
|
requirePuppeteer: true,
|
|
},
|
|
};
|
|
|
|
async function handler(ctx) {
|
|
const { studio } = ctx.req.param();
|
|
|
|
const context = await playwright();
|
|
const response = await playwrightFetch(`${baseUrl}/api/studios/${studio}?page=0`, context);
|
|
|
|
const list = parseList(response.videos);
|
|
|
|
const items = await Promise.all(list.map((item) => cache.tryGet(item.link, () => getItem(item, context))));
|
|
|
|
await context.close();
|
|
|
|
return {
|
|
title: `${response.studio.hotDvdIds?.join(' ') ?? response.studio.name} Jav Online | Japanese Adult Video - JavTrailers.com`,
|
|
description: 'Watch Jav made by Prestige free, with high definition, we have over 4,000 studios available for free streaming.',
|
|
link: `${baseUrl}/studios/${studio}`,
|
|
item: items,
|
|
};
|
|
}
|