From 698fcd54f8348194c33f06e300cf0e4af06e3ebd Mon Sep 17 00:00:00 2001 From: Tony Date: Wed, 15 Jan 2025 00:13:18 +0800 Subject: [PATCH] fix(missav): new domain (#18125) --- lib/routes/missav/namespace.ts | 4 ++-- lib/routes/missav/new.ts | 31 +++++++++++++++++++------------ 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/lib/routes/missav/namespace.ts b/lib/routes/missav/namespace.ts index 0b4c91d950..808c12e0a1 100644 --- a/lib/routes/missav/namespace.ts +++ b/lib/routes/missav/namespace.ts @@ -1,7 +1,7 @@ import type { Namespace } from '@/types'; export const namespace: Namespace = { - name: 'MissAV.com', - url: 'missav.com', + name: 'MissAV', + url: 'missav.ws', lang: 'en', }; diff --git a/lib/routes/missav/new.ts b/lib/routes/missav/new.ts index d9e720deee..45d0789860 100644 --- a/lib/routes/missav/new.ts +++ b/lib/routes/missav/new.ts @@ -2,16 +2,16 @@ import { Route } from '@/types'; import { getCurrentPath } from '@/utils/helpers'; const __dirname = getCurrentPath(import.meta.url); -import got from '@/utils/got'; -import { load } from 'cheerio'; +import ofetch from '@/utils/ofetch'; +import * as cheerio from 'cheerio'; import { art } from '@/utils/render'; import path from 'node:path'; +import { config } from '@/config'; export const route: Route = { path: '/new', categories: ['multimedia'], example: '/missav/new', - parameters: {}, features: { requireConfig: false, requirePuppeteer: false, @@ -22,28 +22,35 @@ export const route: Route = { }, radar: [ { - source: ['missav.com/dm397/new', 'missav.com/new', 'missav.com/'], + source: ['missav.ws/dm397/new', 'missav.ws/new', 'missav.ws/'], + }, + { + source: ['missav.ai/dm397/new', 'missav.ai/new', 'missav.ai/'], }, ], name: '最近更新', maintainers: ['TonyRL'], handler, - url: 'missav.com/dm397/new', + url: 'missav.ws/dm397/new', }; async function handler() { - const baseUrl = 'https://missav.com'; - const { data: response } = await got(`${baseUrl}/dm397/new`); - const $ = load(response); + const baseUrl = 'https://missav.ws'; + const response = await ofetch(`${baseUrl}/dm397/new`, { + headers: { + 'User-Agent': config.trueUA, + }, + }); + const $ = cheerio.load(response); const items = $('.grid .group') .toArray() .map((item) => { - item = $(item); - const title = item.find('.text-secondary'); - const poster = new URL(item.find('img').data('src')); + const $item = $(item); + const title = $item.find('.text-secondary'); + const poster = new URL($item.find('img').data('src')); poster.searchParams.set('class', 'normal'); - const video = item.find('video').data('src'); + const video = $item.find('video').data('src'); return { title: title.text().trim(), link: title.attr('href'),