移动云盘预览修复
This commit is contained in:
@@ -221,48 +221,57 @@ 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 response = await fetch(`${BASE_URL}getContentInfoFromOutLink`, {
|
||||||
const raw = await postPlain(
|
method: 'POST',
|
||||||
`${BASE_URL}getContentInfoFromOutLink`,
|
headers: {
|
||||||
requestPayload,
|
'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',
|
||||||
false,
|
Accept: 'application/json, text/plain, */*',
|
||||||
auth
|
'Accept-Encoding': 'gzip, deflate, br, zstd',
|
||||||
);
|
'Content-Type': 'application/json',
|
||||||
let parsed: any;
|
...(authorization ? { authorization: ensureHeaderSafeAuthorization(authorization) } : {}),
|
||||||
try {
|
},
|
||||||
parsed = JSON.parse(raw);
|
body: JSON.stringify(requestPayload),
|
||||||
} catch {
|
cache: 'no-store',
|
||||||
lastErrorMessage = '移动云盘播放接口返回异常';
|
});
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const contentInfo = parsed?.data?.contentInfo || parsed?.contentInfo;
|
const raw = await response.text();
|
||||||
const playUrl =
|
if (!response.ok) {
|
||||||
contentInfo?.presentURL ||
|
throw new Error(`移动云盘播放接口请求失败 (${response.status})`);
|
||||||
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 : '未获取到移动云盘播放地址';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let parsed: any;
|
||||||
|
try {
|
||||||
|
parsed = typeof raw === 'string' ? JSON.parse(raw) : raw;
|
||||||
|
} catch {
|
||||||
|
throw new Error('移动云盘播放接口返回异常');
|
||||||
|
}
|
||||||
|
|
||||||
|
const playUrl =
|
||||||
|
parsed?.data?.contentInfo?.presentURL ||
|
||||||
|
parsed?.data?.contentInfo?.presentUrl ||
|
||||||
|
parsed?.data?.contentInfo?.playUrl ||
|
||||||
|
parsed?.data?.contentInfo?.url ||
|
||||||
|
parsed?.contentInfo?.presentURL ||
|
||||||
|
parsed?.contentInfo?.presentUrl ||
|
||||||
|
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);
|
throw new Error(lastErrorMessage);
|
||||||
|
|||||||
Reference in New Issue
Block a user