磁链增加代理配置

This commit is contained in:
mtvpls
2026-03-25 10:30:22 +08:00
parent f24c42cb90
commit cc1e70ad61
8 changed files with 219 additions and 10 deletions
+11 -4
View File
@@ -3,6 +3,8 @@ import { NextRequest, NextResponse } from 'next/server';
import { parseStringPromise } from 'xml2js';
import { getAuthInfoFromCookie } from '@/lib/auth';
import { getConfig } from '@/lib/config';
import { getMagnetBaseUrl, universalMagnetFetch } from '@/lib/magnet.client';
export const runtime = 'nodejs';
@@ -48,11 +50,17 @@ export async function POST(req: NextRequest) {
}
// 请求 acg.rip RSS
const searchUrl = `https://acg.rip/page/${pageNum}.xml?term=${encodeURIComponent(trimmedKeyword)}`;
const config = await getConfig();
const searchBaseUrl = getMagnetBaseUrl(
'https://acg.rip',
config.SiteConfig.MagnetAcgripReverseProxy
);
const searchUrl = `${searchBaseUrl}/page/${pageNum}.xml?term=${encodeURIComponent(trimmedKeyword)}`;
const response = await fetch(searchUrl, {
const response = await universalMagnetFetch(searchUrl, config.SiteConfig.MagnetProxy, {
headers: {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36',
'User-Agent':
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36',
},
});
@@ -123,4 +131,3 @@ export async function POST(req: NextRequest) {
);
}
}
+8 -2
View File
@@ -3,6 +3,8 @@ import { NextRequest, NextResponse } from 'next/server';
import { parseStringPromise } from 'xml2js';
import { getAuthInfoFromCookie } from '@/lib/auth';
import { getConfig } from '@/lib/config';
import { getMagnetBaseUrl, universalMagnetFetch } from '@/lib/magnet.client';
export const runtime = 'nodejs';
@@ -56,11 +58,15 @@ export async function POST(req: NextRequest) {
});
}
const baseUrl = 'http://share.dmhy.org/topics/rss/rss.xml';
const config = await getConfig();
const baseUrl = `${getMagnetBaseUrl(
'http://share.dmhy.org',
config.SiteConfig.MagnetDmhyReverseProxy
)}/topics/rss/rss.xml`;
const params = new URLSearchParams({ keyword: trimmedKeyword });
const searchUrl = `${baseUrl}?${params.toString()}`;
const response = await fetch(searchUrl, {
const response = await universalMagnetFetch(searchUrl, config.SiteConfig.MagnetProxy, {
headers: {
'User-Agent':
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36',
+11 -4
View File
@@ -3,6 +3,8 @@ import { NextRequest, NextResponse } from 'next/server';
import { parseStringPromise } from 'xml2js';
import { getAuthInfoFromCookie } from '@/lib/auth';
import { getConfig } from '@/lib/config';
import { getMagnetBaseUrl, universalMagnetFetch } from '@/lib/magnet.client';
export const runtime = 'nodejs';
@@ -62,11 +64,17 @@ export async function POST(req: NextRequest) {
});
}
const searchUrl = `https://mikanani.me/RSS/Search?searchstr=${encodeURIComponent(trimmedKeyword)}`;
const config = await getConfig();
const searchBaseUrl = getMagnetBaseUrl(
'https://mikanani.me',
config.SiteConfig.MagnetMikanReverseProxy
);
const searchUrl = `${searchBaseUrl}/RSS/Search?searchstr=${encodeURIComponent(trimmedKeyword)}`;
const response = await fetch(searchUrl, {
const response = await universalMagnetFetch(searchUrl, config.SiteConfig.MagnetProxy, {
headers: {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36',
'User-Agent':
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36',
},
});
@@ -144,4 +152,3 @@ export async function POST(req: NextRequest) {
);
}
}
+16
View File
@@ -50,6 +50,10 @@ export async function POST(request: NextRequest) {
PansouUsername,
PansouPassword,
PansouKeywordBlocklist,
MagnetProxy,
MagnetMikanReverseProxy,
MagnetDmhyReverseProxy,
MagnetAcgripReverseProxy,
EnableComments,
CustomAdFilterCode,
CustomAdFilterVersion,
@@ -91,6 +95,10 @@ export async function POST(request: NextRequest) {
PansouUsername?: string;
PansouPassword?: string;
PansouKeywordBlocklist?: string;
MagnetProxy?: string;
MagnetMikanReverseProxy?: string;
MagnetDmhyReverseProxy?: string;
MagnetAcgripReverseProxy?: string;
EnableComments: boolean;
CustomAdFilterCode?: string;
CustomAdFilterVersion?: number;
@@ -132,6 +140,10 @@ export async function POST(request: NextRequest) {
(BannerDataSource !== undefined && typeof BannerDataSource !== 'string') ||
(RecommendationDataSource !== undefined && typeof RecommendationDataSource !== 'string') ||
(PansouKeywordBlocklist !== undefined && typeof PansouKeywordBlocklist !== 'string') ||
(MagnetProxy !== undefined && typeof MagnetProxy !== 'string') ||
(MagnetMikanReverseProxy !== undefined && typeof MagnetMikanReverseProxy !== 'string') ||
(MagnetDmhyReverseProxy !== undefined && typeof MagnetDmhyReverseProxy !== 'string') ||
(MagnetAcgripReverseProxy !== undefined && typeof MagnetAcgripReverseProxy !== 'string') ||
typeof EnableComments !== 'boolean' ||
(CustomAdFilterCode !== undefined && typeof CustomAdFilterCode !== 'string') ||
(CustomAdFilterVersion !== undefined && typeof CustomAdFilterVersion !== 'number') ||
@@ -188,6 +200,10 @@ export async function POST(request: NextRequest) {
PansouUsername,
PansouPassword,
PansouKeywordBlocklist,
MagnetProxy,
MagnetMikanReverseProxy,
MagnetDmhyReverseProxy,
MagnetAcgripReverseProxy,
EnableComments,
CustomAdFilterCode,
CustomAdFilterVersion,