移动云盘在线播放
This commit is contained in:
@@ -3706,14 +3706,19 @@ const NetDiskConfigComponent = ({
|
||||
const [savePath, setSavePath] = useState('/');
|
||||
const [playTempSavePath, setPlayTempSavePath] = useState('/');
|
||||
const [openListTempPath, setOpenListTempPath] = useState('/');
|
||||
const [mobileEnabled, setMobileEnabled] = useState(false);
|
||||
const [mobileAuthorization, setMobileAuthorization] = useState('');
|
||||
|
||||
useEffect(() => {
|
||||
const quark = config?.NetDiskConfig?.Quark;
|
||||
const mobile = config?.NetDiskConfig?.Mobile;
|
||||
setEnabled(quark?.Enabled || false);
|
||||
setCookie(quark?.Cookie || '');
|
||||
setSavePath(quark?.SavePath || '/');
|
||||
setPlayTempSavePath(quark?.PlayTempSavePath || '/');
|
||||
setOpenListTempPath(quark?.OpenListTempPath || '/');
|
||||
setMobileEnabled(mobile?.Enabled || false);
|
||||
setMobileAuthorization(mobile?.Authorization || '');
|
||||
}, [config]);
|
||||
|
||||
const handleSave = async () => {
|
||||
@@ -3730,6 +3735,10 @@ const NetDiskConfigComponent = ({
|
||||
PlayTempSavePath: playTempSavePath,
|
||||
OpenListTempPath: openListTempPath,
|
||||
},
|
||||
Mobile: {
|
||||
Enabled: mobileEnabled,
|
||||
Authorization: mobileAuthorization,
|
||||
},
|
||||
}),
|
||||
});
|
||||
|
||||
@@ -3772,6 +3781,34 @@ const NetDiskConfigComponent = ({
|
||||
});
|
||||
};
|
||||
|
||||
const handleValidateMobile = async () => {
|
||||
await withLoading('validateMobileNetDisk', async () => {
|
||||
try {
|
||||
const response = await fetch('/api/admin/netdisk', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
action: 'validate',
|
||||
provider: 'mobile',
|
||||
Mobile: {
|
||||
Authorization: mobileAuthorization,
|
||||
},
|
||||
}),
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
if (!response.ok) {
|
||||
throw new Error(data.error || '校验失败');
|
||||
}
|
||||
|
||||
showSuccess(data.message || '移动云盘验证头格式正常', showAlert);
|
||||
} catch (error) {
|
||||
showError(error instanceof Error ? error.message : '校验失败', showAlert);
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<div className='space-y-6'>
|
||||
<details className='pt-4 border-t border-gray-200 dark:border-gray-700'>
|
||||
@@ -3891,6 +3928,64 @@ const NetDiskConfigComponent = ({
|
||||
</div>
|
||||
</details>
|
||||
|
||||
<details className='pt-4 border-t border-gray-200 dark:border-gray-700'>
|
||||
<summary className='text-sm font-semibold text-gray-900 dark:text-gray-100 cursor-pointer'>
|
||||
移动云盘
|
||||
</summary>
|
||||
<div className='mt-4 space-y-4'>
|
||||
<div className='flex items-center justify-between p-4 bg-gray-50 dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700'>
|
||||
<div>
|
||||
<h3 className='text-sm font-medium text-gray-900 dark:text-gray-100'>
|
||||
启用移动云盘
|
||||
</h3>
|
||||
<p className='text-xs text-gray-500 dark:text-gray-400 mt-1'>
|
||||
开启后,网盘搜索中的移动云盘资源会显示“立即播放”按钮
|
||||
</p>
|
||||
</div>
|
||||
<label className='relative inline-flex items-center cursor-pointer'>
|
||||
<input
|
||||
type='checkbox'
|
||||
checked={mobileEnabled}
|
||||
onChange={(e) => setMobileEnabled(e.target.checked)}
|
||||
className='sr-only peer'
|
||||
/>
|
||||
<div className="w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-pink-300 dark:peer-focus:ring-pink-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full rtl:peer-checked:after:-translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:start-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-pink-600"></div>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className='block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2'>
|
||||
验证头
|
||||
</label>
|
||||
<textarea
|
||||
value={mobileAuthorization}
|
||||
onChange={(e) => setMobileAuthorization(e.target.value)}
|
||||
disabled={!mobileEnabled}
|
||||
rows={5}
|
||||
placeholder='粘贴移动云盘验证头'
|
||||
className='w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 focus:ring-2 focus:ring-pink-500 focus:border-transparent disabled:opacity-50 disabled:cursor-not-allowed'
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className='flex gap-3'>
|
||||
<button
|
||||
onClick={handleValidateMobile}
|
||||
disabled={!mobileEnabled || !mobileAuthorization || isLoading('validateMobileNetDisk')}
|
||||
className={buttonStyles.primary}
|
||||
>
|
||||
{isLoading('validateMobileNetDisk') ? '校验中...' : '校验移动云盘验证头'}
|
||||
</button>
|
||||
<button
|
||||
onClick={handleSave}
|
||||
disabled={isLoading('saveNetDisk')}
|
||||
className={buttonStyles.success}
|
||||
>
|
||||
{isLoading('saveNetDisk') ? '保存中...' : '保存配置'}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
|
||||
<AlertModal
|
||||
isOpen={alertModal.isOpen}
|
||||
onClose={hideAlert}
|
||||
|
||||
@@ -5,6 +5,10 @@ import { NextRequest, NextResponse } from 'next/server';
|
||||
import { getAuthInfoFromCookie } from '@/lib/auth';
|
||||
import { getConfig, setCachedConfig } from '@/lib/config';
|
||||
import { db } from '@/lib/db';
|
||||
import {
|
||||
assertMobileAuthorizationHeaderSafe,
|
||||
normalizeMobileAuthorization,
|
||||
} from '@/lib/netdisk/mobile.client';
|
||||
import {
|
||||
assertQuarkCookieHeaderSafe,
|
||||
normalizeQuarkCookie,
|
||||
@@ -40,11 +44,14 @@ export async function POST(request: NextRequest) {
|
||||
}
|
||||
|
||||
const body = await request.json();
|
||||
const { action, Quark } = body;
|
||||
const { action, Quark, Mobile, provider } = body;
|
||||
const adminConfig = await getConfig();
|
||||
|
||||
if (action === 'save') {
|
||||
const normalizedCookie = Quark?.Cookie ? assertQuarkCookieHeaderSafe(Quark.Cookie) : '';
|
||||
const normalizedMobileAuthorization = Mobile?.Authorization
|
||||
? assertMobileAuthorizationHeaderSafe(Mobile.Authorization)
|
||||
: '';
|
||||
|
||||
adminConfig.NetDiskConfig = adminConfig.NetDiskConfig || {};
|
||||
adminConfig.NetDiskConfig.Quark = {
|
||||
@@ -54,6 +61,10 @@ export async function POST(request: NextRequest) {
|
||||
PlayTempSavePath: Quark?.PlayTempSavePath || '/',
|
||||
OpenListTempPath: Quark?.OpenListTempPath || '/',
|
||||
};
|
||||
adminConfig.NetDiskConfig.Mobile = {
|
||||
Enabled: Boolean(Mobile?.Enabled),
|
||||
Authorization: normalizedMobileAuthorization,
|
||||
};
|
||||
|
||||
await db.saveAdminConfig(adminConfig);
|
||||
await setCachedConfig(adminConfig);
|
||||
@@ -62,10 +73,21 @@ export async function POST(request: NextRequest) {
|
||||
}
|
||||
|
||||
if (action === 'validate') {
|
||||
if (provider === 'mobile') {
|
||||
if (!Mobile?.Authorization) {
|
||||
return NextResponse.json({ error: '请先填写移动云盘 Authorization' }, { status: 400 });
|
||||
}
|
||||
|
||||
normalizeMobileAuthorization(Mobile.Authorization);
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
message: '移动云盘 Authorization 格式正常',
|
||||
});
|
||||
}
|
||||
|
||||
if (!Quark?.Cookie) {
|
||||
return NextResponse.json({ error: '请先填写夸克 Cookie' }, { status: 400 });
|
||||
}
|
||||
|
||||
await validateQuarkCookieReadable(normalizeQuarkCookie(Quark.Cookie));
|
||||
|
||||
return NextResponse.json({
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
|
||||
import { getAuthInfoFromCookie } from '@/lib/auth';
|
||||
import { getConfig } from '@/lib/config';
|
||||
import { listMobileShareVideos } from '@/lib/netdisk/mobile.client';
|
||||
import { createMobileNetdiskSession } from '@/lib/netdisk/mobile-session-cache';
|
||||
import { NETDISK_MOBILE_SOURCE } from '@/lib/netdisk/source';
|
||||
import { hasFeaturePermission } from '@/lib/permissions';
|
||||
|
||||
export const runtime = 'nodejs';
|
||||
|
||||
export async function POST(request: NextRequest) {
|
||||
try {
|
||||
const authInfo = getAuthInfoFromCookie(request);
|
||||
if (!authInfo?.username) {
|
||||
return NextResponse.json({ error: '未登录' }, { status: 401 });
|
||||
}
|
||||
if (!(await hasFeaturePermission(authInfo.username, 'netdisk_temp_play'))) {
|
||||
return NextResponse.json({ error: '无权限使用临时播放' }, { status: 403 });
|
||||
}
|
||||
|
||||
const { shareUrl, passcode, title } = await request.json();
|
||||
if (!shareUrl) {
|
||||
return NextResponse.json({ error: '分享链接不能为空' }, { status: 400 });
|
||||
}
|
||||
|
||||
const config = await getConfig();
|
||||
const mobileConfig = config.NetDiskConfig?.Mobile;
|
||||
if (!mobileConfig?.Enabled || !mobileConfig.Authorization) {
|
||||
return NextResponse.json({ error: '移动云盘未配置或未启用' }, { status: 400 });
|
||||
}
|
||||
|
||||
const result = await listMobileShareVideos(shareUrl, mobileConfig.Authorization);
|
||||
const session = createMobileNetdiskSession({
|
||||
title: title || result.title,
|
||||
shareUrl,
|
||||
passcode,
|
||||
files: result.files,
|
||||
});
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
source: NETDISK_MOBILE_SOURCE,
|
||||
id: session.id,
|
||||
title: title || result.title,
|
||||
totalFiles: result.files.length,
|
||||
expiresAt: session.expiresAt,
|
||||
});
|
||||
} catch (error) {
|
||||
return NextResponse.json(
|
||||
{ error: error instanceof Error ? error.message : '立即播放失败' },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
|
||||
import { getAuthInfoFromCookie } from '@/lib/auth';
|
||||
import { getConfig } from '@/lib/config';
|
||||
import {
|
||||
getMobileShareDownloadUrl,
|
||||
getMobileSharePlayUrl,
|
||||
listMobileShareVideos,
|
||||
} from '@/lib/netdisk/mobile.client';
|
||||
import {
|
||||
createMobileNetdiskSession,
|
||||
getMobileNetdiskSession,
|
||||
parseMobileNetdiskId,
|
||||
refreshMobileNetdiskSession,
|
||||
} from '@/lib/netdisk/mobile-session-cache';
|
||||
|
||||
export const runtime = 'nodejs';
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
try {
|
||||
const authInfo = getAuthInfoFromCookie(request);
|
||||
if (!authInfo?.username) {
|
||||
return NextResponse.json({ error: '未授权' }, { status: 401 });
|
||||
}
|
||||
|
||||
const { searchParams } = new URL(request.url);
|
||||
const sessionId = searchParams.get('id') || searchParams.get('session');
|
||||
const episodeIndexRaw = searchParams.get('episodeIndex');
|
||||
const format = searchParams.get('format');
|
||||
|
||||
if (!sessionId || episodeIndexRaw == null) {
|
||||
return NextResponse.json({ error: '缺少参数' }, { status: 400 });
|
||||
}
|
||||
|
||||
const episodeIndex = Number.parseInt(episodeIndexRaw, 10);
|
||||
if (!Number.isInteger(episodeIndex) || episodeIndex < 0) {
|
||||
return NextResponse.json({ error: '无效的 episodeIndex' }, { status: 400 });
|
||||
}
|
||||
|
||||
const config = await getConfig();
|
||||
const mobileConfig = config.NetDiskConfig?.Mobile;
|
||||
if (!mobileConfig?.Enabled || !mobileConfig.Authorization) {
|
||||
return NextResponse.json({ error: '移动云盘未配置或未启用' }, { status: 400 });
|
||||
}
|
||||
|
||||
let session = refreshMobileNetdiskSession(sessionId) || getMobileNetdiskSession(sessionId);
|
||||
if (!session) {
|
||||
const payload = parseMobileNetdiskId(sessionId);
|
||||
const result = await listMobileShareVideos(payload.shareUrl, mobileConfig.Authorization);
|
||||
session = createMobileNetdiskSession({
|
||||
title: result.title,
|
||||
shareUrl: payload.shareUrl,
|
||||
passcode: payload.passcode,
|
||||
files: result.files,
|
||||
});
|
||||
}
|
||||
|
||||
const file = session.files[episodeIndex];
|
||||
if (!file) {
|
||||
return NextResponse.json({ error: '播放文件不存在' }, { status: 404 });
|
||||
}
|
||||
|
||||
let url = '';
|
||||
try {
|
||||
url = await getMobileSharePlayUrl(
|
||||
file.contentId,
|
||||
file.linkID,
|
||||
mobileConfig.Authorization
|
||||
);
|
||||
} catch {
|
||||
url = await getMobileShareDownloadUrl(
|
||||
file.contentId,
|
||||
file.linkID,
|
||||
mobileConfig.Authorization
|
||||
);
|
||||
}
|
||||
refreshMobileNetdiskSession(sessionId);
|
||||
|
||||
if (format === 'json') {
|
||||
return NextResponse.json({ url, headers: {} });
|
||||
}
|
||||
|
||||
return NextResponse.redirect(url);
|
||||
} catch (error) {
|
||||
return NextResponse.json(
|
||||
{ error: error instanceof Error ? error.message : '获取播放地址失败' },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import { NextRequest, NextResponse } from 'next/server';
|
||||
import { getAuthInfoFromCookie } from '@/lib/auth';
|
||||
import { getConfig } from '@/lib/config';
|
||||
import { createQuarkInstantPlayFolder } from '@/lib/netdisk/quark.client';
|
||||
import { NETDISK_QUARK_SOURCE } from '@/lib/netdisk/source';
|
||||
import { hasFeaturePermission } from '@/lib/permissions';
|
||||
import { base58Encode } from '@/lib/utils';
|
||||
|
||||
@@ -76,7 +77,7 @@ export async function POST(request: NextRequest) {
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
source: 'quark-temp',
|
||||
source: NETDISK_QUARK_SOURCE,
|
||||
id: base58Encode(openlistFolderPath),
|
||||
title: title || result.folderName,
|
||||
openlistFolderPath,
|
||||
|
||||
@@ -6,6 +6,13 @@ import { getAuthInfoFromCookie } from '@/lib/auth';
|
||||
import { getAvailableApiSites, getCacheTime, getConfig } from '@/lib/config';
|
||||
import { getDetailFromApiV2 } from '@/lib/downstream';
|
||||
import { getProxyToken } from '@/lib/emby-token';
|
||||
import {
|
||||
createMobileNetdiskSession,
|
||||
getMobileNetdiskSession,
|
||||
parseMobileNetdiskId,
|
||||
refreshMobileNetdiskSession,
|
||||
} from '@/lib/netdisk/mobile-session-cache';
|
||||
import { LEGACY_QUARK_TEMP_SOURCE, NETDISK_MOBILE_SOURCE, NETDISK_QUARK_SOURCE, normalizeNetdiskSource } from '@/lib/netdisk/source';
|
||||
import {
|
||||
executeSavedSourceScript,
|
||||
normalizeScriptDetailResult,
|
||||
@@ -27,7 +34,7 @@ export async function GET(request: NextRequest) {
|
||||
|
||||
const { searchParams } = new URL(request.url);
|
||||
const id = searchParams.get('id');
|
||||
const sourceCode = searchParams.get('source');
|
||||
const sourceCode = normalizeNetdiskSource(searchParams.get('source'));
|
||||
const fileName = searchParams.get('fileName'); // 小雅源:用户点击的文件名
|
||||
const title = searchParams.get('title');
|
||||
|
||||
@@ -275,7 +282,79 @@ export async function GET(request: NextRequest) {
|
||||
}
|
||||
}
|
||||
|
||||
if (sourceCode === 'quark-temp') {
|
||||
if (sourceCode === NETDISK_MOBILE_SOURCE) {
|
||||
try {
|
||||
const config = await getConfig();
|
||||
const mobileConfig = config.NetDiskConfig?.Mobile;
|
||||
if (!mobileConfig?.Enabled || !mobileConfig.Authorization) {
|
||||
throw new Error('移动云盘未配置或未启用');
|
||||
}
|
||||
|
||||
let session = refreshMobileNetdiskSession(id) || getMobileNetdiskSession(id);
|
||||
if (!session) {
|
||||
const payload = parseMobileNetdiskId(id);
|
||||
const { listMobileShareVideos } = await import('@/lib/netdisk/mobile.client');
|
||||
const result = await listMobileShareVideos(payload.shareUrl, mobileConfig.Authorization);
|
||||
session = createMobileNetdiskSession({
|
||||
title: title || result.title,
|
||||
shareUrl: payload.shareUrl,
|
||||
passcode: payload.passcode,
|
||||
files: result.files,
|
||||
});
|
||||
}
|
||||
if (!session) {
|
||||
throw new Error('移动云盘播放信息恢复失败');
|
||||
}
|
||||
const mobileSession = session;
|
||||
const { parseVideoFileName } = await import('@/lib/video-parser');
|
||||
const parsedFiles = mobileSession.files.map((file, index) => {
|
||||
const parsed = parseVideoFileName(file.name);
|
||||
return {
|
||||
...file,
|
||||
originalIndex: index,
|
||||
sortEpisode: parsed.episode || index + 1,
|
||||
isOVA: parsed.isOVA,
|
||||
displayTitle:
|
||||
parsed.title ||
|
||||
(parsed.episode ? `第${parsed.episode}集` : file.name),
|
||||
};
|
||||
}).sort((a, b) => {
|
||||
if (a.isOVA && !b.isOVA) return 1;
|
||||
if (!a.isOVA && b.isOVA) return -1;
|
||||
return a.sortEpisode !== b.sortEpisode
|
||||
? a.sortEpisode - b.sortEpisode
|
||||
: a.name.localeCompare(b.name, 'zh-Hans-CN', {
|
||||
numeric: true,
|
||||
sensitivity: 'base',
|
||||
});
|
||||
});
|
||||
|
||||
const episodes = parsedFiles.map((file) => (
|
||||
`/api/netdisk/mobile/play?id=${encodeURIComponent(mobileSession.id)}&episodeIndex=${file.originalIndex}`
|
||||
));
|
||||
|
||||
return NextResponse.json({
|
||||
source: NETDISK_MOBILE_SOURCE,
|
||||
source_name: '移动云盘',
|
||||
id: mobileSession.id,
|
||||
title: title || mobileSession.title,
|
||||
poster: '',
|
||||
year: '',
|
||||
douban_id: 0,
|
||||
desc: `移动云盘分享:${mobileSession.shareUrl}`,
|
||||
episodes,
|
||||
episodes_titles: parsedFiles.map((file) => file.displayTitle),
|
||||
proxyMode: false,
|
||||
});
|
||||
} catch (error) {
|
||||
return NextResponse.json(
|
||||
{ error: (error as Error).message },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (sourceCode === NETDISK_QUARK_SOURCE || sourceCode === LEGACY_QUARK_TEMP_SOURCE) {
|
||||
try {
|
||||
const config = await getConfig();
|
||||
const openListConfig = config.OpenListConfig;
|
||||
@@ -390,7 +469,7 @@ export async function GET(request: NextRequest) {
|
||||
});
|
||||
|
||||
return NextResponse.json({
|
||||
source: 'quark-temp',
|
||||
source: NETDISK_QUARK_SOURCE,
|
||||
source_name: '夸克临时播放',
|
||||
id,
|
||||
title: title || folderPath.split('/').filter(Boolean).pop() || '夸克临时播放',
|
||||
|
||||
+57
-39
@@ -8,8 +8,8 @@ import { Suspense, useEffect, useMemo, useRef, useState } from 'react';
|
||||
|
||||
import { getAuthInfoFromBrowserCookie } from '@/lib/auth';
|
||||
import {
|
||||
convertDanmakuFormat,
|
||||
clearDanmakuCacheByTitle,
|
||||
convertDanmakuFormat,
|
||||
getDanmakuById,
|
||||
getDanmakuFromCache,
|
||||
getEpisodes,
|
||||
@@ -54,12 +54,13 @@ import {
|
||||
pruneLocalEpisodeProgressStorage,
|
||||
saveLocalEpisodeProgress,
|
||||
} from '@/lib/episode-progress';
|
||||
import { getTMDBImageUrl } from '@/lib/tmdb.search';
|
||||
import { isNetdiskSource, normalizeNetdiskSource } from '@/lib/netdisk/source';
|
||||
import {
|
||||
getRecommendationCache,
|
||||
recommendationCacheKeys,
|
||||
setRecommendationCache,
|
||||
} from '@/lib/recommendations/cache';
|
||||
import { getTMDBImageUrl } from '@/lib/tmdb.search';
|
||||
import { DanmakuFilterConfig, EpisodeFilterConfig, SearchResult } from '@/lib/types';
|
||||
import { base58Decode, getVideoResolutionFromM3u8, processImageUrl } from '@/lib/utils';
|
||||
import { useEnableAIComments } from '@/hooks/useEnableAIComments';
|
||||
@@ -605,27 +606,28 @@ function PlayPageClient() {
|
||||
|
||||
// 纠错后的描述信息(用于显示,不触发 detail 更新)
|
||||
const [correctedDesc, setCorrectedDesc] = useState<string>('');
|
||||
const [quarkTempTMDBMeta, setQuarkTempTMDBMeta] = useState<{
|
||||
const [netdiskTMDBMeta, setNetdiskTMDBMeta] = useState<{
|
||||
desc?: string;
|
||||
poster?: string;
|
||||
year?: string;
|
||||
tmdbId?: number;
|
||||
} | null>(null);
|
||||
const [pendingQuarkTempTMDBData, setPendingQuarkTempTMDBData] = useState<any | null>(null);
|
||||
const [pendingNetdiskTMDBData, setPendingNetdiskTMDBData] = useState<any | null>(null);
|
||||
|
||||
// 当前源和ID - source 直接存储完整格式(如 'emby_wumei' 或 'emby')
|
||||
const [currentSource, setCurrentSource] = useState(searchParams.get('source') || '');
|
||||
const [currentSource, setCurrentSource] = useState(normalizeNetdiskSource(searchParams.get('source')) || '');
|
||||
const [currentId, setCurrentId] = useState(searchParams.get('id') || '');
|
||||
const [fileName] = useState(searchParams.get('fileName') || ''); // 小雅源:用户点击的文件名
|
||||
const isDirectPlay = currentSource === 'directplay';
|
||||
|
||||
useEffect(() => {
|
||||
setQuarkTempTMDBMeta(null);
|
||||
setPendingQuarkTempTMDBData(null);
|
||||
setNetdiskTMDBMeta(null);
|
||||
setPendingNetdiskTMDBData(null);
|
||||
}, [currentSource, currentId]);
|
||||
|
||||
// 解析 source 参数以获取 embyKey(仅用于 API 调用)
|
||||
const parseSourceForApi = (source: string): { source: string; embyKey?: string } => {
|
||||
source = normalizeNetdiskSource(source);
|
||||
if (source.startsWith('emby_')) {
|
||||
const key = source.substring(5);
|
||||
return { source: 'emby', embyKey: key };
|
||||
@@ -1300,19 +1302,22 @@ function PlayPageClient() {
|
||||
|
||||
const populatePlayMetadataFromTMDB = (tmdbData: any) => {
|
||||
const currentDetail = detailRef.current;
|
||||
if (!currentDetail || currentDetail.source !== 'quark-temp') {
|
||||
setPendingQuarkTempTMDBData(tmdbData);
|
||||
if (!currentDetail || !isNetdiskSource(currentDetail.source)) {
|
||||
setPendingNetdiskTMDBData(tmdbData);
|
||||
return;
|
||||
}
|
||||
|
||||
const tmdbYear = tmdbData.releaseDate?.split('-')[0] || '';
|
||||
const shouldReplaceDesc = !currentDetail.desc || currentDetail.desc.startsWith('临时播放目录:');
|
||||
const shouldReplaceDesc =
|
||||
!currentDetail.desc ||
|
||||
currentDetail.desc.startsWith('临时播放目录:') ||
|
||||
currentDetail.desc.startsWith('移动云盘分享:');
|
||||
|
||||
const resolvedTmdbId = typeof tmdbData.tmdbId === 'string'
|
||||
? Number(String(tmdbData.tmdbId).split(':')[1] || 0)
|
||||
: tmdbData.tmdbId;
|
||||
|
||||
setQuarkTempTMDBMeta({
|
||||
setNetdiskTMDBMeta({
|
||||
desc: shouldReplaceDesc ? (tmdbData.overview || currentDetail.desc) : currentDetail.desc,
|
||||
poster: currentDetail.poster || tmdbData.poster || '',
|
||||
year: currentDetail.year || tmdbYear,
|
||||
@@ -1320,7 +1325,7 @@ function PlayPageClient() {
|
||||
});
|
||||
|
||||
setDetail((prev) => {
|
||||
if (!prev || prev.source !== 'quark-temp') {
|
||||
if (!prev || !isNetdiskSource(prev.source)) {
|
||||
return prev;
|
||||
}
|
||||
|
||||
@@ -1381,25 +1386,32 @@ function PlayPageClient() {
|
||||
|
||||
useEffect(() => {
|
||||
if (
|
||||
pendingQuarkTempTMDBData &&
|
||||
detail?.source === 'quark-temp'
|
||||
pendingNetdiskTMDBData &&
|
||||
isNetdiskSource(detail?.source)
|
||||
) {
|
||||
const pending = pendingQuarkTempTMDBData;
|
||||
setPendingQuarkTempTMDBData(null);
|
||||
const currentDetail = detail;
|
||||
if (!currentDetail) {
|
||||
return;
|
||||
}
|
||||
const pending = pendingNetdiskTMDBData;
|
||||
setPendingNetdiskTMDBData(null);
|
||||
const tmdbYear = pending.releaseDate?.split('-')[0] || '';
|
||||
const shouldReplaceDesc = !detail.desc || detail.desc.startsWith('临时播放目录:');
|
||||
const shouldReplaceDesc =
|
||||
!currentDetail.desc ||
|
||||
currentDetail.desc.startsWith('临时播放目录:') ||
|
||||
currentDetail.desc.startsWith('移动云盘分享:');
|
||||
const resolvedTmdbId = typeof pending.tmdbId === 'string'
|
||||
? Number(String(pending.tmdbId).split(':')[1] || 0)
|
||||
: pending.tmdbId;
|
||||
|
||||
setQuarkTempTMDBMeta({
|
||||
desc: shouldReplaceDesc ? (pending.overview || detail.desc) : detail.desc,
|
||||
poster: detail.poster || pending.poster || '',
|
||||
year: detail.year || tmdbYear,
|
||||
tmdbId: detail.tmdb_id || resolvedTmdbId,
|
||||
setNetdiskTMDBMeta({
|
||||
desc: shouldReplaceDesc ? (pending.overview || currentDetail.desc) : currentDetail.desc,
|
||||
poster: currentDetail.poster || pending.poster || '',
|
||||
year: currentDetail.year || tmdbYear,
|
||||
tmdbId: currentDetail.tmdb_id || resolvedTmdbId,
|
||||
});
|
||||
|
||||
setDetail((prev) => prev && prev.source === 'quark-temp' ? {
|
||||
setDetail((prev) => prev && isNetdiskSource(prev.source) ? {
|
||||
...prev,
|
||||
poster: prev.poster || pending.poster || '',
|
||||
year: prev.year || tmdbYear,
|
||||
@@ -1407,17 +1419,17 @@ function PlayPageClient() {
|
||||
tmdb_id: prev.tmdb_id || resolvedTmdbId,
|
||||
} : prev);
|
||||
|
||||
if (pending.poster && !detail.poster) {
|
||||
if (pending.poster && !currentDetail.poster) {
|
||||
setVideoCover(processImageUrl(pending.poster));
|
||||
}
|
||||
if (tmdbYear && !detail.year) {
|
||||
if (tmdbYear && !currentDetail.year) {
|
||||
setVideoYear(tmdbYear);
|
||||
}
|
||||
if (pending.overview) {
|
||||
setCorrectedDesc(pending.overview);
|
||||
}
|
||||
}
|
||||
}, [pendingQuarkTempTMDBData, detail]);
|
||||
}, [pendingNetdiskTMDBData, detail]);
|
||||
|
||||
// 视频播放地址
|
||||
const [videoUrl, setVideoUrl] = useState('');
|
||||
@@ -1535,7 +1547,7 @@ function PlayPageClient() {
|
||||
!isM3u8LikeUrl(videoUrl) &&
|
||||
(
|
||||
detail.source === 'openlist' ||
|
||||
detail.source === 'quark-temp' ||
|
||||
isNetdiskSource(detail.source) ||
|
||||
detail.source === 'xiaoya' ||
|
||||
detail.source.startsWith('emby')
|
||||
)
|
||||
@@ -4165,7 +4177,7 @@ function PlayPageClient() {
|
||||
|
||||
// 监听 URL 参数变化,处理换源和换视频(用于房员跟随房主操作)
|
||||
useEffect(() => {
|
||||
const urlSource = searchParams.get('source');
|
||||
const urlSource = normalizeNetdiskSource(searchParams.get('source'));
|
||||
const urlId = searchParams.get('id');
|
||||
|
||||
// 只在URL参数存在且与当前状态不同时才处理
|
||||
@@ -9639,12 +9651,12 @@ function PlayPageClient() {
|
||||
</span>
|
||||
)}
|
||||
{/* 优先使用 doubanYear,如果没有则使用 detail.year 或 videoYear */}
|
||||
{(doubanYear || quarkTempTMDBMeta?.year || detail?.year || videoYear) && (
|
||||
<span>{doubanYear || quarkTempTMDBMeta?.year || detail?.year || videoYear}</span>
|
||||
{(doubanYear || netdiskTMDBMeta?.year || detail?.year || videoYear) && (
|
||||
<span>{doubanYear || netdiskTMDBMeta?.year || detail?.year || videoYear}</span>
|
||||
)}
|
||||
{detail?.source_name && (
|
||||
<span
|
||||
className={`relative group cursor-pointer border px-2 py-[1px] rounded ${detail.source === 'xiaoya' ? 'border-blue-500' : detail.source === 'quark-temp' ? 'border-purple-500' : detail.source === 'openlist' || detail.source === 'emby' || detail.source?.startsWith('emby_') ? 'border-yellow-500' : 'border-gray-500/60'
|
||||
className={`relative group cursor-pointer border px-2 py-[1px] rounded ${detail.source === 'xiaoya' ? 'border-blue-500' : isNetdiskSource(detail.source) ? 'border-purple-500' : detail.source === 'openlist' || detail.source === 'emby' || detail.source?.startsWith('emby_') ? 'border-yellow-500' : 'border-gray-500/60'
|
||||
}`}
|
||||
onClick={fetchCurrentSourceVideoInfo}
|
||||
>
|
||||
@@ -9664,7 +9676,7 @@ function PlayPageClient() {
|
||||
{detail?.type_name && <span>{detail.type_name}</span>}
|
||||
</div>
|
||||
{/* 剧情简介 */}
|
||||
{(doubanCardSubtitle || quarkTempTMDBMeta?.desc || correctedDesc || detail?.desc) && (
|
||||
{(doubanCardSubtitle || netdiskTMDBMeta?.desc || correctedDesc || detail?.desc) && (
|
||||
<div
|
||||
className={`mt-0 text-base leading-relaxed opacity-90 overflow-y-auto pr-2 flex-1 min-h-0 scrollbar-hide ${tmdbBackdrop ? 'text-white' : ''}`}
|
||||
style={{ whiteSpace: 'pre-line' }}
|
||||
@@ -9675,7 +9687,7 @@ function PlayPageClient() {
|
||||
{doubanCardSubtitle}
|
||||
</div>
|
||||
)}
|
||||
{quarkTempTMDBMeta?.desc || correctedDesc || detail?.desc}
|
||||
{netdiskTMDBMeta?.desc || correctedDesc || detail?.desc}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
@@ -9720,9 +9732,15 @@ function PlayPageClient() {
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<span className='text-gray-600 dark:text-gray-400'>
|
||||
封面图片
|
||||
</span>
|
||||
isNetdiskSource(detail?.source) ? (
|
||||
<div className='flex flex-col items-center justify-center text-gray-500 dark:text-gray-400'>
|
||||
<Cloud className='w-16 h-16 opacity-80' />
|
||||
</div>
|
||||
) : (
|
||||
<span className='text-gray-600 dark:text-gray-400'>
|
||||
封面图片
|
||||
</span>
|
||||
)
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
@@ -9929,7 +9947,7 @@ function PlayPageClient() {
|
||||
// 特殊源使用 tmdb,其他使用 cms(通过 doubanId)
|
||||
// 如果有豆瓣ID且不为0,传入doubanId
|
||||
detail.source === 'openlist' ||
|
||||
detail.source === 'quark-temp' ||
|
||||
isNetdiskSource(detail.source) ||
|
||||
detail.source?.startsWith('emby') ||
|
||||
detail.source === 'xiaoya'
|
||||
? undefined
|
||||
@@ -9940,7 +9958,7 @@ function PlayPageClient() {
|
||||
tmdbId={
|
||||
// 特殊源使用 tmdb
|
||||
detail.source === 'openlist' ||
|
||||
detail.source === 'quark-temp' ||
|
||||
isNetdiskSource(detail.source) ||
|
||||
detail.source?.startsWith('emby') ||
|
||||
detail.source === 'xiaoya'
|
||||
? detail.tmdb_id
|
||||
@@ -9952,7 +9970,7 @@ function PlayPageClient() {
|
||||
// 非特殊源使用 cms 数据
|
||||
// 但如果有豆瓣ID且不为0,则不传入cmsData,优先使用豆瓣数据
|
||||
detail.source !== 'openlist' &&
|
||||
detail.source !== 'quark-temp' &&
|
||||
!isNetdiskSource(detail.source) &&
|
||||
!detail.source?.startsWith('emby') &&
|
||||
detail.source !== 'xiaoya' &&
|
||||
!(detail.douban_id && detail.douban_id !== 0)
|
||||
|
||||
+49
-37
@@ -962,40 +962,6 @@ function SearchPageClient() {
|
||||
}, [activeTab]);
|
||||
|
||||
useEffect(() => {
|
||||
// 从 URL 读取搜索类型参数
|
||||
const typeParam = searchParams.get('type');
|
||||
const query = searchParams.get('q');
|
||||
|
||||
if (
|
||||
(typeParam === 'pansou' && netdiskSearchEnabled) ||
|
||||
(typeParam === 'acg' && magnetSearchEnabled)
|
||||
) {
|
||||
setActiveTab(typeParam);
|
||||
|
||||
// 如果有搜索关键词且显示结果,触发对应的搜索
|
||||
if (query && query.trim()) {
|
||||
setSearchQuery(query);
|
||||
setShowResults(true);
|
||||
|
||||
// 延迟触发搜索,确保组件已经切换到正确的标签页
|
||||
setTimeout(() => {
|
||||
if (typeParam === 'pansou') {
|
||||
setTriggerPansouSearch((prev) => !prev);
|
||||
} else if (typeParam === 'acg') {
|
||||
setTriggerAcgSearch((prev) => !prev);
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
} else if (typeParam === 'video') {
|
||||
setActiveTab('video');
|
||||
} else if (!typeParam && query) {
|
||||
// 如果没有 type 参数但有查询,默认为 video
|
||||
setActiveTab('video');
|
||||
}
|
||||
|
||||
// 无搜索参数时聚焦搜索框
|
||||
!searchParams.get('q') && document.getElementById('searchInput')?.focus();
|
||||
|
||||
// 获取用户权限
|
||||
const authInfo = getAuthInfoFromBrowserCookie();
|
||||
setUserRole(authInfo?.role || null);
|
||||
@@ -1095,6 +1061,31 @@ function SearchPageClient() {
|
||||
};
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const typeParam = searchParams.get('type');
|
||||
const query = searchParams.get('q');
|
||||
|
||||
if (typeParam === 'pansou') {
|
||||
if (netdiskSearchEnabled) {
|
||||
setActiveTab('pansou');
|
||||
} else {
|
||||
setActiveTab('video');
|
||||
}
|
||||
} else if (typeParam === 'acg') {
|
||||
if (magnetSearchEnabled) {
|
||||
setActiveTab('acg');
|
||||
} else {
|
||||
setActiveTab('video');
|
||||
}
|
||||
} else {
|
||||
setActiveTab('video');
|
||||
}
|
||||
|
||||
if (!query) {
|
||||
document.getElementById('searchInput')?.focus();
|
||||
}
|
||||
}, [searchParams, netdiskSearchEnabled, magnetSearchEnabled]);
|
||||
|
||||
useEffect(() => {
|
||||
// 等待转换器初始化完成
|
||||
if (!converterReady) {
|
||||
@@ -1348,7 +1339,27 @@ function SearchPageClient() {
|
||||
setShowResults(false);
|
||||
setShowSuggestions(false);
|
||||
}
|
||||
}, [searchParams, forceRefresh, converterReady, netdiskSearchEnabled, magnetSearchEnabled]);
|
||||
}, [searchParams, forceRefresh, converterReady]);
|
||||
|
||||
useEffect(() => {
|
||||
const typeParam = searchParams.get('type');
|
||||
const query = searchParams.get('q');
|
||||
if (!query || !query.trim()) return;
|
||||
|
||||
if (typeParam === 'pansou' && netdiskSearchEnabled) {
|
||||
setSearchQuery(query);
|
||||
setShowResults(true);
|
||||
setTimeout(() => {
|
||||
setTriggerPansouSearch((prev) => !prev);
|
||||
}, 100);
|
||||
} else if (typeParam === 'acg' && magnetSearchEnabled) {
|
||||
setSearchQuery(query);
|
||||
setShowResults(true);
|
||||
setTimeout(() => {
|
||||
setTriggerAcgSearch((prev) => !prev);
|
||||
}, 100);
|
||||
}
|
||||
}, [searchParams, netdiskSearchEnabled, magnetSearchEnabled]);
|
||||
|
||||
// 组件卸载时,关闭可能存在的连接
|
||||
useEffect(() => {
|
||||
@@ -1553,8 +1564,9 @@ function SearchPageClient() {
|
||||
setSearchQuery(trimmed);
|
||||
setShowResults(true);
|
||||
setShowSuggestions(false);
|
||||
|
||||
router.push(`/search?q=${encodeURIComponent(trimmed)}`);
|
||||
router.push(
|
||||
`/search?q=${encodeURIComponent(trimmed)}&type=${activeTab}`
|
||||
);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -14,6 +14,7 @@ import type { DanmakuComment,DanmakuSelection } from '@/lib/danmaku/types';
|
||||
import { generateStorageKey, getCachedPlayRecordsSnapshot } from '@/lib/db.client';
|
||||
import { isEpisodeHiddenByFilter } from '@/lib/episode-filter';
|
||||
import { loadAllLocalEpisodeProgressRecords } from '@/lib/episode-progress';
|
||||
import { isNetdiskSource } from '@/lib/netdisk/source';
|
||||
import { EpisodeFilterConfig,SearchResult } from '@/lib/types';
|
||||
import { getVideoResolutionFromM3u8 } from '@/lib/utils';
|
||||
|
||||
@@ -1001,7 +1002,7 @@ const EpisodeSelector: React.FC<EpisodeSelectorProps> = ({
|
||||
{/* 源名称和集数信息 - 垂直居中 */}
|
||||
<div className='flex items-center justify-between'>
|
||||
<span className={`text-xs px-2 py-1 border rounded text-gray-700 dark:text-gray-300 ${
|
||||
source.source === 'xiaoya' ? 'border-blue-500' : source.source === 'quark-temp' ? 'border-purple-500' : source.source === 'openlist' || source.source === 'emby' || source.source?.startsWith('emby_')
|
||||
source.source === 'xiaoya' ? 'border-blue-500' : isNetdiskSource(source.source) ? 'border-purple-500' : source.source === 'openlist' || source.source === 'emby' || source.source?.startsWith('emby_')
|
||||
? 'border-yellow-500'
|
||||
: 'border-gray-500/60'
|
||||
}`}>
|
||||
|
||||
@@ -5,9 +5,10 @@ import { AlertCircle, Copy, ExternalLink, Loader2, RefreshCw } from 'lucide-reac
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
|
||||
import Toast, { ToastProps } from '@/components/Toast';
|
||||
import { PansouLink, PansouSearchResult } from '@/lib/pansou.client';
|
||||
|
||||
import Toast, { ToastProps } from '@/components/Toast';
|
||||
|
||||
interface PansouSearchProps {
|
||||
keyword: string;
|
||||
triggerSearch?: boolean; // 触发搜索的标志
|
||||
@@ -108,7 +109,7 @@ export default function PansouSearch({
|
||||
}
|
||||
|
||||
searchPansou();
|
||||
}, [triggerSearch, searchPansou]); // 依赖 triggerSearch 和 searchPansou
|
||||
}, [triggerSearch]); // 只在触发标志变化时搜索,避免 keyword 变化自动搜索
|
||||
|
||||
const handleCopy = async (text: string, url: string) => {
|
||||
try {
|
||||
@@ -159,10 +160,10 @@ export default function PansouSearch({
|
||||
}
|
||||
};
|
||||
|
||||
const handleQuarkInstantPlay = async (link: PansouLink) => {
|
||||
const handleNetdiskInstantPlay = async (cloudType: string, link: PansouLink) => {
|
||||
try {
|
||||
setPlayingUrl(link.url);
|
||||
const response = await fetch('/api/netdisk/quark/instant-play', {
|
||||
const response = await fetch(cloudType === 'mobile' ? '/api/netdisk/mobile/instant-play' : '/api/netdisk/quark/instant-play', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@@ -180,7 +181,7 @@ export default function PansouSearch({
|
||||
}
|
||||
|
||||
router.push(
|
||||
`/play?source=quark-temp&id=${encodeURIComponent(data.id)}&title=${encodeURIComponent(data.title || keyword)}`
|
||||
`/play?source=${encodeURIComponent(data.source || (cloudType === 'mobile' ? 'netdisk-mobile' : 'netdisk-quark'))}&id=${encodeURIComponent(data.id)}&title=${encodeURIComponent(data.title || keyword)}`
|
||||
);
|
||||
} catch (err: any) {
|
||||
setToast({
|
||||
@@ -338,24 +339,26 @@ export default function PansouSearch({
|
||||
|
||||
{/* 操作按钮 */}
|
||||
<div className='flex items-center gap-1 flex-shrink-0'>
|
||||
{cloudType === 'quark' && (
|
||||
{(cloudType === 'quark' || cloudType === 'mobile') && (
|
||||
<>
|
||||
<button
|
||||
onClick={() => handleQuarkInstantPlay(link)}
|
||||
onClick={() => handleNetdiskInstantPlay(cloudType, link)}
|
||||
disabled={playingUrl === link.url}
|
||||
className='px-2 py-1 rounded-md bg-green-600 hover:bg-green-700 text-white text-xs transition-colors disabled:opacity-60'
|
||||
title='立即播放'
|
||||
>
|
||||
{playingUrl === link.url ? '处理中...' : '立即播放'}
|
||||
</button>
|
||||
<button
|
||||
onClick={() => handleQuarkTransfer(link)}
|
||||
disabled={transferingUrl === link.url}
|
||||
className='px-2 py-1 rounded-md bg-purple-600 hover:bg-purple-700 text-white text-xs transition-colors disabled:opacity-60'
|
||||
title='转存到配置目录'
|
||||
>
|
||||
{transferingUrl === link.url ? '转存中...' : '转存'}
|
||||
</button>
|
||||
{cloudType === 'quark' && (
|
||||
<button
|
||||
onClick={() => handleQuarkTransfer(link)}
|
||||
disabled={transferingUrl === link.url}
|
||||
className='px-2 py-1 rounded-md bg-purple-600 hover:bg-purple-700 text-white text-xs transition-colors disabled:opacity-60'
|
||||
title='转存到配置目录'
|
||||
>
|
||||
{transferingUrl === link.url ? '转存中...' : '转存'}
|
||||
</button>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
<button
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any,react-hooks/exhaustive-deps,@typescript-eslint/no-empty-function */
|
||||
|
||||
import { ExternalLink, Heart, Info, Link, PlayCircleIcon, Radio, Sparkles, Trash2 } from 'lucide-react';
|
||||
import { Cloud, ExternalLink, Heart, Info, Link, PlayCircleIcon, Radio, Sparkles, Trash2 } from 'lucide-react';
|
||||
import Image from 'next/image';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import React, {
|
||||
@@ -21,11 +21,12 @@ import {
|
||||
saveFavorite,
|
||||
subscribeToDataUpdates,
|
||||
} from '@/lib/db.client';
|
||||
import { isNetdiskSource } from '@/lib/netdisk/source';
|
||||
import {
|
||||
processImageUrl,
|
||||
base58Decode,
|
||||
tryApplyDoubanImageFallback,
|
||||
getDoubanImageFallbackUrl,
|
||||
processImageUrl,
|
||||
tryApplyDoubanImageFallback,
|
||||
} from '@/lib/utils';
|
||||
import { useLongPress } from '@/hooks/useLongPress';
|
||||
|
||||
@@ -112,7 +113,25 @@ const VideoCard = forwardRef<VideoCardHandle, VideoCardProps>(function VideoCard
|
||||
const router = useRouter();
|
||||
const actualTitle = title;
|
||||
const actualPoster = poster;
|
||||
const processedPoster = useMemo(() => processImageUrl(actualPoster), [actualPoster]);
|
||||
const netdiskPosterPlaceholder = useMemo(() => {
|
||||
return `data:image/svg+xml;utf8,${encodeURIComponent(`
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 600">
|
||||
<rect width="400" height="600" fill="#f3f4f6"/>
|
||||
<g fill="none" stroke="#9ca3af" stroke-width="16" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M118 332c-30.9 0-56-25.1-56-56 0-28.5 21.3-52 48.9-55.4C120.6 184.7 154.8 160 195 160c51.1 0 92.9 39.2 97.1 89.2 27.3 4.2 47.9 27.7 47.9 56.8 0 32-26 58-58 58H118z"/>
|
||||
</g>
|
||||
</svg>
|
||||
`)}`;
|
||||
}, []);
|
||||
const processedPoster = useMemo(
|
||||
() =>
|
||||
actualPoster
|
||||
? processImageUrl(actualPoster)
|
||||
: isNetdiskSource(source)
|
||||
? netdiskPosterPlaceholder
|
||||
: '',
|
||||
[actualPoster, source, netdiskPosterPlaceholder]
|
||||
);
|
||||
const [favorited, setFavorited] = useState(false);
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [showMobileActions, setShowMobileActions] = useState(false);
|
||||
@@ -747,6 +766,10 @@ const VideoCard = forwardRef<VideoCardHandle, VideoCardProps>(function VideoCard
|
||||
<div className='absolute inset-0 flex items-center justify-center bg-gray-200/80 dark:bg-gray-700/80'>
|
||||
<Link className='w-8 h-8 text-blue-500' />
|
||||
</div>
|
||||
) : (isNetdiskSource(actualSource) && !actualPoster && displayPoster === netdiskPosterPlaceholder) ? (
|
||||
<div className='absolute inset-0 flex flex-col items-center justify-center bg-gray-100 dark:bg-gray-800 text-gray-500 dark:text-gray-400'>
|
||||
<Cloud className='w-10 h-10 opacity-80' />
|
||||
</div>
|
||||
) : (
|
||||
<Image
|
||||
src={displayPoster}
|
||||
@@ -1061,7 +1084,7 @@ const VideoCard = forwardRef<VideoCardHandle, VideoCardProps>(function VideoCard
|
||||
>
|
||||
<span
|
||||
className={`inline-block border rounded px-1 py-0.5 text-[8px] text-white/90 bg-black/60 ${
|
||||
actualSource === 'xiaoya' ? 'border-blue-500' : actualSource === 'quark-temp' ? 'border-purple-500' : actualSource === 'openlist' || actualSource === 'emby' || actualSource?.startsWith('emby_') ? 'border-yellow-500' : origin === 'live' ? 'border-red-500' : 'border-white/60'
|
||||
actualSource === 'xiaoya' ? 'border-blue-500' : isNetdiskSource(actualSource) ? 'border-purple-500' : actualSource === 'openlist' || actualSource === 'emby' || actualSource?.startsWith('emby_') ? 'border-yellow-500' : origin === 'live' ? 'border-red-500' : 'border-white/60'
|
||||
}`}
|
||||
style={{
|
||||
WebkitUserSelect: 'none',
|
||||
@@ -1385,7 +1408,7 @@ const VideoCard = forwardRef<VideoCardHandle, VideoCardProps>(function VideoCard
|
||||
{config.showSourceName && source_name && !cmsData && (
|
||||
<span
|
||||
className={`inline-block border rounded px-1 py-0.5 text-[8px] text-white/90 bg-black/30 backdrop-blur-sm ${
|
||||
actualSource === 'xiaoya' ? 'border-blue-500' : actualSource === 'quark-temp' ? 'border-purple-500' : actualSource === 'openlist' || actualSource === 'emby' || actualSource?.startsWith('emby_') ? 'border-yellow-500' : 'border-white/60'
|
||||
actualSource === 'xiaoya' ? 'border-blue-500' : isNetdiskSource(actualSource) ? 'border-purple-500' : actualSource === 'openlist' || actualSource === 'emby' || actualSource?.startsWith('emby_') ? 'border-yellow-500' : 'border-white/60'
|
||||
}`}
|
||||
style={{
|
||||
WebkitUserSelect: 'none',
|
||||
|
||||
@@ -154,6 +154,10 @@ export interface AdminConfig {
|
||||
PlayTempSavePath: string;
|
||||
OpenListTempPath: string;
|
||||
};
|
||||
Mobile?: {
|
||||
Enabled: boolean;
|
||||
Authorization: string;
|
||||
};
|
||||
};
|
||||
AIConfig?: {
|
||||
Enabled: boolean; // 是否启用AI问片功能
|
||||
|
||||
@@ -672,6 +672,10 @@ export function configSelfCheck(adminConfig: AdminConfig): AdminConfig {
|
||||
PlayTempSavePath: '/',
|
||||
OpenListTempPath: '/',
|
||||
},
|
||||
Mobile: {
|
||||
Enabled: false,
|
||||
Authorization: '',
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -685,6 +689,13 @@ export function configSelfCheck(adminConfig: AdminConfig): AdminConfig {
|
||||
};
|
||||
}
|
||||
|
||||
if (!adminConfig.NetDiskConfig.Mobile) {
|
||||
adminConfig.NetDiskConfig.Mobile = {
|
||||
Enabled: false,
|
||||
Authorization: '',
|
||||
};
|
||||
}
|
||||
|
||||
// 确保音乐配置存在
|
||||
if (!adminConfig.MusicConfig) {
|
||||
adminConfig.MusicConfig = {
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
import { base58Decode, base58Encode } from '@/lib/utils';
|
||||
|
||||
export interface MobileNetdiskSessionFile {
|
||||
name: string;
|
||||
contentId: string;
|
||||
linkID: string;
|
||||
size?: number;
|
||||
}
|
||||
|
||||
export interface MobileNetdiskSession {
|
||||
id: string;
|
||||
provider: 'mobile';
|
||||
title: string;
|
||||
shareUrl: string;
|
||||
passcode?: string;
|
||||
files: MobileNetdiskSessionFile[];
|
||||
createdAt: number;
|
||||
expiresAt: number;
|
||||
}
|
||||
|
||||
const TTL_MS = 30 * 60 * 1000;
|
||||
const sessionStore = new Map<string, MobileNetdiskSession>();
|
||||
|
||||
export function buildMobileNetdiskId(input: {
|
||||
shareUrl: string;
|
||||
passcode?: string;
|
||||
}): string {
|
||||
return base58Encode(JSON.stringify({
|
||||
shareUrl: input.shareUrl,
|
||||
passcode: input.passcode || '',
|
||||
}));
|
||||
}
|
||||
|
||||
export function parseMobileNetdiskId(id: string): {
|
||||
shareUrl: string;
|
||||
passcode?: string;
|
||||
} {
|
||||
try {
|
||||
const decoded = base58Decode(id);
|
||||
const parsed = JSON.parse(decoded);
|
||||
if (!parsed?.shareUrl || typeof parsed.shareUrl !== 'string') {
|
||||
throw new Error('invalid mobile netdisk id');
|
||||
}
|
||||
return {
|
||||
shareUrl: parsed.shareUrl,
|
||||
passcode: typeof parsed.passcode === 'string' ? parsed.passcode : '',
|
||||
};
|
||||
} catch {
|
||||
throw new Error('无效的移动云盘播放 ID');
|
||||
}
|
||||
}
|
||||
|
||||
function pruneExpiredSessions() {
|
||||
const now = Date.now();
|
||||
for (const [key, value] of Array.from(sessionStore.entries())) {
|
||||
if (value.expiresAt <= now) {
|
||||
sessionStore.delete(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function createMobileNetdiskSession(input: {
|
||||
title: string;
|
||||
shareUrl: string;
|
||||
passcode?: string;
|
||||
files: MobileNetdiskSessionFile[];
|
||||
}): MobileNetdiskSession {
|
||||
pruneExpiredSessions();
|
||||
const now = Date.now();
|
||||
const id = buildMobileNetdiskId({
|
||||
shareUrl: input.shareUrl,
|
||||
passcode: input.passcode,
|
||||
});
|
||||
const session: MobileNetdiskSession = {
|
||||
id,
|
||||
provider: 'mobile',
|
||||
title: input.title,
|
||||
shareUrl: input.shareUrl,
|
||||
passcode: input.passcode,
|
||||
files: input.files,
|
||||
createdAt: now,
|
||||
expiresAt: now + TTL_MS,
|
||||
};
|
||||
sessionStore.set(session.id, session);
|
||||
return session;
|
||||
}
|
||||
|
||||
export function getMobileNetdiskSession(id: string): MobileNetdiskSession | null {
|
||||
pruneExpiredSessions();
|
||||
const session = sessionStore.get(id);
|
||||
if (!session) return null;
|
||||
if (session.expiresAt <= Date.now()) {
|
||||
sessionStore.delete(id);
|
||||
return null;
|
||||
}
|
||||
return session;
|
||||
}
|
||||
|
||||
export function refreshMobileNetdiskSession(id: string): MobileNetdiskSession | null {
|
||||
const session = getMobileNetdiskSession(id);
|
||||
if (!session) return null;
|
||||
session.expiresAt = Date.now() + TTL_MS;
|
||||
sessionStore.set(id, session);
|
||||
return session;
|
||||
}
|
||||
@@ -0,0 +1,330 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
|
||||
import { createCipheriv, createDecipheriv, randomBytes } from 'crypto';
|
||||
|
||||
export interface MobileShareVideoFile {
|
||||
name: string;
|
||||
contentId: string;
|
||||
linkID: string;
|
||||
size: number;
|
||||
}
|
||||
|
||||
export interface MobileShareListResult {
|
||||
title: string;
|
||||
files: MobileShareVideoFile[];
|
||||
}
|
||||
|
||||
function ensureHeaderSafeAuthorization(authorization: string): string {
|
||||
const raw = authorization.trim();
|
||||
const normalized = /^basic\s+/i.test(raw) ? raw.replace(/^basic\s+/i, 'Basic ') : `Basic ${raw}`;
|
||||
|
||||
for (let i = 0; i < normalized.length; i += 1) {
|
||||
if (normalized.charCodeAt(i) > 255) {
|
||||
throw new Error('移动云盘 Authorization 含有非法字符,请检查是否包含中文标点或说明文字');
|
||||
}
|
||||
}
|
||||
|
||||
return normalized;
|
||||
}
|
||||
|
||||
export function normalizeMobileAuthorization(authorization: string): string {
|
||||
return ensureHeaderSafeAuthorization(authorization);
|
||||
}
|
||||
|
||||
export function assertMobileAuthorizationHeaderSafe(authorization: string): string {
|
||||
return ensureHeaderSafeAuthorization(authorization);
|
||||
}
|
||||
|
||||
const SHARE_ID_PATTERNS = [
|
||||
/https:\/\/yun\.139\.com\/shareweb\/#\/w\/i\/([^&/]+)/,
|
||||
/https:\/\/yun\.139\.com\/sharewap\/#\/m\/i\?([^&/]+)/,
|
||||
/https:\/\/caiyun\.139\.com\/m\/i\?([^&/]+)/,
|
||||
/https:\/\/caiyun\.139\.com\/w\/i\/([^&/]+)/,
|
||||
];
|
||||
|
||||
const BASE_URL = 'https://share-kd-njs.yun.139.com/yun-share/richlifeApp/devapp/IOutLink/';
|
||||
const ALTERNATIVE_URLS = [
|
||||
'https://cloud.139.com/yun-share/richlifeApp/devapp/IOutLink/',
|
||||
'https://yun.139.com/yun-share/richlifeApp/devapp/IOutLink/',
|
||||
'https://share.yun.139.com/yun-share/richlifeApp/devapp/IOutLink/',
|
||||
];
|
||||
const AES_KEY = Buffer.from('PVGDwmcvfs1uV3d1', 'utf8');
|
||||
const BASE_HEADERS: HeadersInit = {
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36',
|
||||
Accept: 'application/json, text/plain, */*',
|
||||
'Content-Type': 'application/json',
|
||||
'hcy-cool-flag': '1',
|
||||
'x-deviceinfo': '||3|12.27.0|chrome|136.0.0.0|189f4426ca008b9cbe9bf9bd79723d77||windows 10|1536X695|zh-CN|||',
|
||||
Origin: 'https://yun.139.com',
|
||||
Referer: 'https://yun.139.com/',
|
||||
};
|
||||
|
||||
function normalizeBase64(input: string): string {
|
||||
return input.replace(/-/g, '+').replace(/_/g, '/');
|
||||
}
|
||||
|
||||
function extractAccountFromAuthorization(authorization?: string): string {
|
||||
if (!authorization) return '';
|
||||
try {
|
||||
const normalized = ensureHeaderSafeAuthorization(authorization);
|
||||
const matched = normalized.match(/^Basic\s+(.+)$/i);
|
||||
if (!matched?.[1]) return '';
|
||||
const decoded = Buffer.from(matched[1].trim(), 'base64').toString('utf8');
|
||||
const parts = decoded.split(':');
|
||||
return parts[1]?.trim() || '';
|
||||
} catch {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
function encryptPayload(data: string | object): string {
|
||||
const iv = randomBytes(16);
|
||||
const cipher = createCipheriv('aes-128-cbc', AES_KEY, iv);
|
||||
const plain = typeof data === 'string' ? data : JSON.stringify(data);
|
||||
const encrypted = Buffer.concat([cipher.update(plain, 'utf8'), cipher.final()]);
|
||||
return Buffer.concat([iv, encrypted]).toString('base64');
|
||||
}
|
||||
|
||||
function decryptPayload(data: string): string {
|
||||
const payload = Buffer.from(normalizeBase64(data), 'base64');
|
||||
const iv = payload.subarray(0, 16);
|
||||
const encrypted = payload.subarray(16);
|
||||
const decipher = createDecipheriv('aes-128-cbc', AES_KEY, iv);
|
||||
const decrypted = Buffer.concat([decipher.update(encrypted), decipher.final()]);
|
||||
return decrypted.toString('utf8');
|
||||
}
|
||||
|
||||
function parseShareId(url: string): string {
|
||||
for (const pattern of SHARE_ID_PATTERNS) {
|
||||
const matched = pattern.exec(url);
|
||||
if (matched?.[1]) return matched[1];
|
||||
}
|
||||
throw new Error('无法解析移动云盘分享链接');
|
||||
}
|
||||
|
||||
async function postPlain(
|
||||
url: string,
|
||||
body: string | object,
|
||||
encrypted = false,
|
||||
authorization?: string
|
||||
): Promise<string> {
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
...BASE_HEADERS,
|
||||
...(authorization ? { authorization: ensureHeaderSafeAuthorization(authorization) } : {}),
|
||||
},
|
||||
body: encrypted ? encryptPayload(body) : JSON.stringify(body),
|
||||
cache: 'no-store',
|
||||
});
|
||||
|
||||
const text = await response.text();
|
||||
if (!response.ok) {
|
||||
throw new Error(`移动云盘接口请求失败 (${response.status})`);
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
async function fetchShareInfo(linkId: string, pCaID: string, authorization?: string) {
|
||||
const requestPayload = {
|
||||
getOutLinkInfoReq: {
|
||||
account: '',
|
||||
linkID: linkId,
|
||||
passwd: '',
|
||||
caSrt: 1,
|
||||
coSrt: 1,
|
||||
srtDr: 0,
|
||||
bNum: 1,
|
||||
pCaID,
|
||||
eNum: 200,
|
||||
},
|
||||
commonAccountInfo: { account: '', accountType: 1 },
|
||||
};
|
||||
|
||||
let lastError: unknown;
|
||||
for (const baseUrl of [BASE_URL, ...ALTERNATIVE_URLS]) {
|
||||
try {
|
||||
const raw = await postPlain(`${baseUrl}getOutLinkInfoV6`, requestPayload, true, authorization);
|
||||
if (!raw || raw === 'null') {
|
||||
continue;
|
||||
}
|
||||
|
||||
const decrypted = decryptPayload(raw);
|
||||
const parsed = JSON.parse(decrypted);
|
||||
return parsed?.data ?? null;
|
||||
} catch (error) {
|
||||
lastError = error;
|
||||
}
|
||||
}
|
||||
|
||||
throw lastError instanceof Error ? lastError : new Error('获取移动云盘分享信息失败');
|
||||
}
|
||||
|
||||
async function collectFiles(linkId: string, path = 'root', authorization?: string): Promise<MobileShareVideoFile[]> {
|
||||
const info = await fetchShareInfo(linkId, path, authorization);
|
||||
if (!info) return [];
|
||||
|
||||
const currentFiles = Array.isArray(info.coLst)
|
||||
? info.coLst
|
||||
.filter((item: any) => item && item.coType === 3)
|
||||
.map((item: any) => ({
|
||||
name: String(item.coName || '未命名视频'),
|
||||
contentId: String(item.path || ''),
|
||||
linkID: linkId,
|
||||
size: Number(item.coSize || 0),
|
||||
}))
|
||||
.filter((item: MobileShareVideoFile) => item.contentId)
|
||||
: [];
|
||||
|
||||
const childDirs = Array.isArray(info.caLst)
|
||||
? info.caLst
|
||||
.map((item: any) => String(item?.path || ''))
|
||||
.filter(Boolean)
|
||||
: [];
|
||||
|
||||
if (childDirs.length === 0) {
|
||||
return currentFiles;
|
||||
}
|
||||
|
||||
const nested = await Promise.all(
|
||||
childDirs.map((childPath: string) => collectFiles(linkId, childPath, authorization))
|
||||
);
|
||||
return [...currentFiles, ...nested.flat()];
|
||||
}
|
||||
|
||||
function sortFiles(files: MobileShareVideoFile[]): MobileShareVideoFile[] {
|
||||
return [...files].sort((a, b) => a.name.localeCompare(b.name, 'zh-Hans-CN', { numeric: true, sensitivity: 'base' }));
|
||||
}
|
||||
|
||||
export async function listMobileShareVideos(shareUrl: string, authorization?: string): Promise<MobileShareListResult> {
|
||||
const linkId = parseShareId(shareUrl);
|
||||
const files = sortFiles(await collectFiles(linkId, 'root', authorization));
|
||||
if (files.length === 0) {
|
||||
throw new Error('移动云盘分享中没有视频文件');
|
||||
}
|
||||
return {
|
||||
title: files.length === 1 ? files[0].name.replace(/\.[^.]+$/, '') : '移动云盘立即播放',
|
||||
files,
|
||||
};
|
||||
}
|
||||
|
||||
export async function getMobileSharePlayUrl(contentId: string, linkID: string, authorization?: string): Promise<string> {
|
||||
const requestPayload = {
|
||||
getContentInfoFromOutLinkReq: {
|
||||
contentId: contentId.split('/')[1] || contentId,
|
||||
linkID,
|
||||
account: '',
|
||||
},
|
||||
commonAccountInfo: {
|
||||
account: '',
|
||||
accountType: 1,
|
||||
},
|
||||
};
|
||||
|
||||
const authCandidates = authorization ? [undefined, authorization] : [undefined];
|
||||
let lastErrorMessage = '未获取到移动云盘播放地址';
|
||||
|
||||
for (const auth of authCandidates) {
|
||||
try {
|
||||
const raw = await postPlain(
|
||||
`${BASE_URL}getContentInfoFromOutLink`,
|
||||
requestPayload,
|
||||
false,
|
||||
auth
|
||||
);
|
||||
let parsed: any;
|
||||
try {
|
||||
parsed = JSON.parse(raw);
|
||||
} catch {
|
||||
lastErrorMessage = '移动云盘播放接口返回异常';
|
||||
continue;
|
||||
}
|
||||
|
||||
const contentInfo = parsed?.data?.contentInfo || parsed?.contentInfo;
|
||||
const playUrl =
|
||||
contentInfo?.presentURL ||
|
||||
contentInfo?.presentUrl ||
|
||||
contentInfo?.playUrl ||
|
||||
contentInfo?.url ||
|
||||
parsed?.data?.presentURL ||
|
||||
parsed?.data?.url;
|
||||
|
||||
if (playUrl) {
|
||||
return playUrl;
|
||||
}
|
||||
|
||||
lastErrorMessage =
|
||||
parsed?.message ||
|
||||
parsed?.msg ||
|
||||
parsed?.data?.message ||
|
||||
parsed?.data?.msg ||
|
||||
'未获取到移动云盘播放地址';
|
||||
} catch (error) {
|
||||
lastErrorMessage =
|
||||
error instanceof Error ? error.message : '未获取到移动云盘播放地址';
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error(lastErrorMessage);
|
||||
}
|
||||
|
||||
export async function getMobileShareDownloadUrl(
|
||||
contentId: string,
|
||||
linkID: string,
|
||||
authorization?: string
|
||||
): Promise<string> {
|
||||
if (!authorization) {
|
||||
throw new Error('移动云盘未配置验证头');
|
||||
}
|
||||
|
||||
const account = extractAccountFromAuthorization(authorization);
|
||||
if (!account) {
|
||||
throw new Error('无法从移动云盘验证头中解析账号');
|
||||
}
|
||||
|
||||
const requestPayload = {
|
||||
dlFromOutLinkReqV3: {
|
||||
linkID,
|
||||
account,
|
||||
coIDLst: {
|
||||
item: [contentId],
|
||||
},
|
||||
},
|
||||
commonAccountInfo: {
|
||||
account,
|
||||
accountType: 1,
|
||||
},
|
||||
};
|
||||
|
||||
const raw = await postPlain(
|
||||
`${BASE_URL}dlFromOutLinkV3`,
|
||||
requestPayload,
|
||||
true,
|
||||
authorization
|
||||
);
|
||||
|
||||
let parsed: any;
|
||||
try {
|
||||
const decrypted = decryptPayload(raw);
|
||||
parsed = JSON.parse(decrypted);
|
||||
} catch {
|
||||
throw new Error('移动云盘下载接口返回异常');
|
||||
}
|
||||
|
||||
const downloadUrl =
|
||||
parsed?.data?.redrUrl ||
|
||||
parsed?.data?.downloadUrl ||
|
||||
parsed?.data?.url;
|
||||
|
||||
if (!downloadUrl) {
|
||||
throw new Error(
|
||||
parsed?.message ||
|
||||
parsed?.msg ||
|
||||
parsed?.data?.message ||
|
||||
parsed?.data?.msg ||
|
||||
'未获取到移动云盘下载地址'
|
||||
);
|
||||
}
|
||||
|
||||
return downloadUrl;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
export const LEGACY_QUARK_TEMP_SOURCE = 'quark-temp';
|
||||
export const NETDISK_QUARK_SOURCE = 'netdisk-quark';
|
||||
export const NETDISK_MOBILE_SOURCE = 'netdisk-mobile';
|
||||
|
||||
export type NetdiskProvider = 'quark' | 'mobile';
|
||||
|
||||
export function normalizeNetdiskSource(source?: string | null): string {
|
||||
if (!source) return '';
|
||||
if (source === LEGACY_QUARK_TEMP_SOURCE) return NETDISK_QUARK_SOURCE;
|
||||
return source;
|
||||
}
|
||||
|
||||
export function isNetdiskSource(source?: string | null): boolean {
|
||||
const normalized = normalizeNetdiskSource(source);
|
||||
return normalized === NETDISK_QUARK_SOURCE || normalized === NETDISK_MOBILE_SOURCE;
|
||||
}
|
||||
|
||||
export function getNetdiskProvider(source?: string | null): NetdiskProvider | null {
|
||||
const normalized = normalizeNetdiskSource(source);
|
||||
if (normalized === NETDISK_QUARK_SOURCE) return 'quark';
|
||||
if (normalized === NETDISK_MOBILE_SOURCE) return 'mobile';
|
||||
return null;
|
||||
}
|
||||
|
||||
export function isNetdiskQuarkSource(source?: string | null): boolean {
|
||||
return normalizeNetdiskSource(source) === NETDISK_QUARK_SOURCE;
|
||||
}
|
||||
|
||||
export function isNetdiskMobileSource(source?: string | null): boolean {
|
||||
return normalizeNetdiskSource(source) === NETDISK_MOBILE_SOURCE;
|
||||
}
|
||||
Reference in New Issue
Block a user