From 9d74d2a4ae472de438811c36e062d8ff429db0ba Mon Sep 17 00:00:00 2001 From: pseudoyu Date: Fri, 18 Apr 2025 22:58:06 +0800 Subject: [PATCH] fix(route/domp4): use new domain and ofetch util --- lib/routes/domp4/detail.ts | 14 ++++++++------ lib/routes/domp4/latest-movie-bt.ts | 20 ++++++++++---------- lib/routes/domp4/latest.ts | 16 ++++++++-------- lib/routes/domp4/namespace.ts | 10 ++-------- lib/routes/domp4/utils.ts | 10 +++++----- 5 files changed, 33 insertions(+), 37 deletions(-) diff --git a/lib/routes/domp4/detail.ts b/lib/routes/domp4/detail.ts index 390a8c5b43..a67c21bb1e 100644 --- a/lib/routes/domp4/detail.ts +++ b/lib/routes/domp4/detail.ts @@ -1,6 +1,6 @@ import { Route } from '@/types'; import { load } from 'cheerio'; -import got from '@/utils/got'; +import ofetch from '@/utils/ofetch'; import { decodeCipherText, composeMagnetUrl, getUrlType, ensureDomain } from './utils'; @@ -74,7 +74,7 @@ export const route: Route = { path: '/detail/:id', categories: ['multimedia'], example: '/domp4/detail/LBTANI22222I', - parameters: { id: '从剧集详情页 URL 处获取,如:`https://www.mp4kan.com/html/LBTANI22222I.html`,取 `.html` 前面部分' }, + parameters: { id: '从剧集详情页 URL 处获取,如:`https://www.xlmp4.com/html/LBTANI22222I.html`,取 `.html` 前面部分' }, features: { requireConfig: false, requirePuppeteer: false, @@ -85,16 +85,18 @@ export const route: Route = { }, radar: [ { - source: ['domp4.cc/detail/:id'], + source: ['www.xlmp4.com/detail/:id'], }, ], name: '剧集订阅', - maintainers: ['savokiss'], + maintainers: ['savokiss', 'pseudoyu'], handler, description: `::: tip 由于大部分详情页是 \`/html/xxx.html\`,还有部分是 \`/detail/123.html\`,所以此处做了兼容,id 取 \`xxx\` 或者 \`123\` 都可以。 新增 \`second\` 参数,用于选择下载地址二(地址二不可用或者不填都默认地址一),用法: \`/domp4/detail/LBTANI22222I?second=1\`。 + +域名频繁更换,目前使用 www.xlmp4.com :::`, }; @@ -113,8 +115,8 @@ async function handler(ctx) { } const detailUrl = `${ensureDomain(ctx, domain)}/${detailType}/${pureId}.html`; - const res = await got(detailUrl); - const $ = load(res.data); + const res = await ofetch(detailUrl); + const $ = load(res); const list = getItemList($, detailUrl, second); const meta = getMetaInfo($); diff --git a/lib/routes/domp4/latest-movie-bt.ts b/lib/routes/domp4/latest-movie-bt.ts index b9c38a0113..ad75b11f1b 100644 --- a/lib/routes/domp4/latest-movie-bt.ts +++ b/lib/routes/domp4/latest-movie-bt.ts @@ -1,9 +1,9 @@ import { Route } from '@/types'; -import got from '@/utils/got'; +import ofetch from '@/utils/ofetch'; import { load } from 'cheerio'; import { getItemList as detailItemList } from './detail'; -import { defaultDomain, ensureDomain } from './utils'; +import { ensureDomain } from './utils'; import cache from '@/utils/cache'; function getItemList($) { @@ -14,7 +14,7 @@ function getItemList($) { return { title: item.find('a').text(), publishDate: item.find('b').text(), - link: `https://${defaultDomain}${item.find('a').attr('href')}`, // fixed domain for guid + link: `https://www.xlmp4.com${item.find('a').attr('href')}`, // fixed domain for guid }; }) .filter((item) => !item.title.includes('话') && !item.title.includes('集') && !item.title.includes('更新至')); @@ -36,28 +36,28 @@ export const route: Route = { }, radar: [ { - source: ['domp4.cc/', 'domp4.cc/custom/update.html'], + source: ['www.xlmp4.com/', 'www.xlmp4.com/custom/update.html'], }, ], name: '最近更新的电源BT列表', - maintainers: ['xianghuawe'], + maintainers: ['xianghuawe', 'pseudoyu'], handler, - url: 'domp4.cc/', + url: 'www.xlmp4.com/', }; async function handler(ctx) { const { domain, second } = ctx.req.query(); const hostUrl = ensureDomain(ctx, domain); const latestUrl = `${hostUrl}/custom/update.html`; - const res = await got.get(latestUrl); - const $ = load(res.data); + const res = await ofetch(latestUrl); + const $ = load(res); const list = getItemList($); const process = await Promise.all( list.map( async (item) => await cache.tryGet(item.link, async () => { - const response = await got.get(item.link); - const $ = load(response.data); + const response = await ofetch(item.link); + const $ = load(response); return detailItemList($, item.link, second); }) ) diff --git a/lib/routes/domp4/latest.ts b/lib/routes/domp4/latest.ts index c2e6705c74..190798333f 100644 --- a/lib/routes/domp4/latest.ts +++ b/lib/routes/domp4/latest.ts @@ -1,8 +1,8 @@ import { Route } from '@/types'; -import got from '@/utils/got'; +import ofetch from '@/utils/ofetch'; import { load } from 'cheerio'; -import { defaultDomain, ensureDomain } from './utils'; +import { ensureDomain } from './utils'; function getItemList($, type) { const list = $(`#${type} .list-group-item`) @@ -11,7 +11,7 @@ function getItemList($, type) { item = $(item); return { title: item.find('a').text(), - link: `https://${defaultDomain}${item.find('a').attr('href')}`, // fixed domain for guid + link: `https://www.xlmp4.com${item.find('a').attr('href')}`, }; }); return list; @@ -32,13 +32,13 @@ export const route: Route = { }, radar: [ { - source: ['domp4.cc/', 'domp4.cc/custom/update.html'], + source: ['www.xlmp4.com/', 'www.xlmp4.com/custom/update.html'], }, ], name: '最近更新', - maintainers: ['savokiss'], + maintainers: ['savokiss', 'pseudoyu'], handler, - url: 'domp4.cc/', + url: 'www.xlmp4.com/', }; async function handler(ctx) { @@ -48,8 +48,8 @@ async function handler(ctx) { const hostUrl = ensureDomain(ctx, domain); const latestUrl = `${hostUrl}/custom/update.html`; - const res = await got.get(latestUrl); - const $ = load(res.data); + const res = await ofetch(latestUrl); + const $ = load(res); const list = getItemList($, type); return { diff --git a/lib/routes/domp4/namespace.ts b/lib/routes/domp4/namespace.ts index dfe00a80f9..0b1f2771c9 100644 --- a/lib/routes/domp4/namespace.ts +++ b/lib/routes/domp4/namespace.ts @@ -2,15 +2,9 @@ import type { Namespace } from '@/types'; export const namespace: Namespace = { name: 'DoMP4 影视', - url: 'domp4.cc', + url: 'www.xlmp4.com', description: `::: tip -由于网站有多个备用域名,默认使用 \`mp4us.com\`,可以通过在路由最后加上 \`?domain=<域名>\` 切换域名。 - -目前可用域名有: - -\`\`\`javascript -['domp4.cc', 'mp4kan.com', 'mp4us.com', 'wemp4.com', 'dbmp4.com'] -\`\`\` + 域名频繁更换,目前使用 www.xlmp4.com :::`, lang: 'zh-CN', }; diff --git a/lib/routes/domp4/utils.ts b/lib/routes/domp4/utils.ts index 8c8c7b22c1..517fb88e29 100644 --- a/lib/routes/domp4/utils.ts +++ b/lib/routes/domp4/utils.ts @@ -1,9 +1,9 @@ import { config } from '@/config'; import ConfigNotFoundError from '@/errors/types/config-not-found'; -const defaultDomain = 'mp4us.com'; +const defaultDomain = 'www.xlmp4.com'; -const allowedDomains = new Set(['domp4.cc', 'mp4us.com', 'wemp4.com', 'dbmp4.com']); +const allowedDomains = new Set(['www.xlmp4.com']); /** * trackers from https://www.domp4.cc/Style/2020/js/base.js?v=2 @@ -61,11 +61,11 @@ function getUrlType(url) { */ function decodeCipherText(p, a, c, k, e, d) { e = function (c) { - return (c < a ? '' : e(Number.parseInt(c / a))) + ((c = c % a) > 35 ? String.fromCharCode(c + 29) : c.toString(36)); + return (c < a ? '' : e(Number.parseInt((c / a).toString()))) + ((c = c % a) > 35 ? String.fromCharCode(c + 29) : c.toString(36)); }; if (!''.replace(/^/, String)) { while (c--) { - d[e(c)] = k[c] || e(c); + d[e(c.toString())] = k[c] || e(c.toString()); } k = [ function (e) { @@ -79,7 +79,7 @@ function decodeCipherText(p, a, c, k, e, d) { } while (c--) { if (k[c]) { - p = p.replaceAll(new RegExp(String.raw`\b` + e(c) + String.raw`\b`, 'g'), k[c]); + p = p.replaceAll(new RegExp(String.raw`\b` + e(c.toString()) + String.raw`\b`, 'g'), k[c]); } } return p;