openlist和小雅增加禁用预览
This commit is contained in:
@@ -102,6 +102,43 @@ export async function GET(request: NextRequest) {
|
||||
openListConfig.Password
|
||||
);
|
||||
|
||||
// 如果启用了禁用预览视频,直接使用直连方法
|
||||
if (openListConfig.DisableVideoPreview) {
|
||||
const fileResponse = await client.getFile(filePath);
|
||||
|
||||
if (fileResponse.code !== 200 || !fileResponse.data.raw_url) {
|
||||
console.error('[OpenList Play] 获取播放URL失败:', {
|
||||
fileName,
|
||||
code: fileResponse.code,
|
||||
message: fileResponse.message,
|
||||
});
|
||||
return NextResponse.json(
|
||||
{ error: '获取播放链接失败' },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
|
||||
// 如果指定了 format=json,使用 getFinalUrl 并返回 JSON
|
||||
if (format === 'json') {
|
||||
const finalUrl = await getFinalUrl(fileResponse.data.raw_url);
|
||||
|
||||
// 检查URL是否为空
|
||||
if (!finalUrl || finalUrl.trim() === '') {
|
||||
throw new Error('获取到的播放链接为空');
|
||||
}
|
||||
|
||||
return NextResponse.json({ url: finalUrl });
|
||||
}
|
||||
|
||||
// 检查URL是否为空
|
||||
if (!fileResponse.data.raw_url || fileResponse.data.raw_url.trim() === '') {
|
||||
throw new Error('获取到的播放链接为空');
|
||||
}
|
||||
|
||||
// 默认返回重定向(用于 tvbox)
|
||||
return NextResponse.redirect(fileResponse.data.raw_url);
|
||||
}
|
||||
|
||||
// 优先尝试视频预览流方法
|
||||
try {
|
||||
const data = await client.getVideoPreview(filePath);
|
||||
|
||||
Reference in New Issue
Block a user