移动云盘预览修复

This commit is contained in:
mtvpls
2026-04-27 16:01:50 +08:00
parent cf3176ae9c
commit dba22b98b3
+26 -17
View File
@@ -221,31 +221,41 @@ export async function getMobileSharePlayUrl(contentId: string, linkID: string, a
}, },
}; };
const authCandidates = authorization ? [undefined, authorization] : [undefined];
let lastErrorMessage = '未获取到移动云盘播放地址'; let lastErrorMessage = '未获取到移动云盘播放地址';
for (const auth of authCandidates) {
try { try {
const raw = await postPlain( const response = await fetch(`${BASE_URL}getContentInfoFromOutLink`, {
`${BASE_URL}getContentInfoFromOutLink`, method: 'POST',
requestPayload, headers: {
false, 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36',
auth Accept: 'application/json, text/plain, */*',
); 'Accept-Encoding': 'gzip, deflate, br, zstd',
'Content-Type': 'application/json',
...(authorization ? { authorization: ensureHeaderSafeAuthorization(authorization) } : {}),
},
body: JSON.stringify(requestPayload),
cache: 'no-store',
});
const raw = await response.text();
if (!response.ok) {
throw new Error(`移动云盘播放接口请求失败 (${response.status})`);
}
let parsed: any; let parsed: any;
try { try {
parsed = JSON.parse(raw); parsed = typeof raw === 'string' ? JSON.parse(raw) : raw;
} catch { } catch {
lastErrorMessage = '移动云盘播放接口返回异常'; throw new Error('移动云盘播放接口返回异常');
continue;
} }
const contentInfo = parsed?.data?.contentInfo || parsed?.contentInfo;
const playUrl = const playUrl =
contentInfo?.presentURL || parsed?.data?.contentInfo?.presentURL ||
contentInfo?.presentUrl || parsed?.data?.contentInfo?.presentUrl ||
contentInfo?.playUrl || parsed?.data?.contentInfo?.playUrl ||
contentInfo?.url || parsed?.data?.contentInfo?.url ||
parsed?.contentInfo?.presentURL ||
parsed?.contentInfo?.presentUrl ||
parsed?.data?.presentURL || parsed?.data?.presentURL ||
parsed?.data?.url; parsed?.data?.url;
@@ -263,7 +273,6 @@ export async function getMobileSharePlayUrl(contentId: string, linkID: string, a
lastErrorMessage = lastErrorMessage =
error instanceof Error ? error.message : '未获取到移动云盘播放地址'; error instanceof Error ? error.message : '未获取到移动云盘播放地址';
} }
}
throw new Error(lastErrorMessage); throw new Error(lastErrorMessage);
} }