修复未配置TVBOX_SUBSCRIBE_TOKEN不代理emby图片
This commit is contained in:
@@ -41,7 +41,10 @@ export async function GET(
|
||||
|
||||
// 验证 TVBox Token(全局token或用户token)
|
||||
let hasValidToken = false;
|
||||
if (globalToken && requestToken === globalToken) {
|
||||
if (requestToken === 'proxy') {
|
||||
// 使用固定的 'proxy' token,跳过token验证,依赖用户登录验证
|
||||
hasValidToken = false;
|
||||
} else if (globalToken && requestToken === globalToken) {
|
||||
// 全局token
|
||||
hasValidToken = true;
|
||||
} else {
|
||||
@@ -73,8 +76,8 @@ export async function GET(
|
||||
// 获取 Emby 客户端
|
||||
const client = await getEmbyClient(embyKey);
|
||||
|
||||
// 获取图片 URL
|
||||
const imageUrl = client.getImageUrl(itemId, imageType, maxWidth);
|
||||
// 获取图片 URL(强制获取直接URL,避免代理循环)
|
||||
const imageUrl = client.getImageUrl(itemId, imageType, maxWidth, undefined, true);
|
||||
|
||||
// 构建请求头,添加自定义 User-Agent
|
||||
const requestHeaders: HeadersInit = {
|
||||
|
||||
@@ -42,7 +42,10 @@ export async function GET(
|
||||
|
||||
// 验证 TVBox Token(全局token或用户token)
|
||||
let hasValidToken = false;
|
||||
if (globalToken && requestToken === globalToken) {
|
||||
if (requestToken === 'proxy') {
|
||||
// 使用固定的 'proxy' token,跳过token验证,依赖用户登录验证
|
||||
hasValidToken = false;
|
||||
} else if (globalToken && requestToken === globalToken) {
|
||||
// 全局token
|
||||
hasValidToken = true;
|
||||
} else {
|
||||
|
||||
@@ -426,15 +426,17 @@ export class EmbyClient {
|
||||
}
|
||||
}
|
||||
|
||||
getImageUrl(itemId: string, imageType: 'Primary' | 'Backdrop' | 'Logo' = 'Primary', maxWidth?: number, proxyToken?: string): string {
|
||||
// 如果启用了代理播放且提供了 token,返回代理 URL
|
||||
if (this.proxyPlay && proxyToken) {
|
||||
getImageUrl(itemId: string, imageType: 'Primary' | 'Backdrop' | 'Logo' = 'Primary', maxWidth?: number, proxyToken?: string, forceDirectUrl = false): string {
|
||||
// 如果启用了代理播放且不是强制获取直接URL,返回代理 URL
|
||||
if (this.proxyPlay && !forceDirectUrl) {
|
||||
// 使用固定的token占位符,实际验证在服务端进行
|
||||
const subscribeToken = proxyToken || 'proxy';
|
||||
const params = new URLSearchParams();
|
||||
params.set('imageType', imageType);
|
||||
if (maxWidth) params.set('maxWidth', maxWidth.toString());
|
||||
if (this.embyKey) params.set('embyKey', this.embyKey);
|
||||
|
||||
return `/api/emby/image/${proxyToken}/${itemId}?${params.toString()}`;
|
||||
return `/api/emby/image/${subscribeToken}/${itemId}?${params.toString()}`;
|
||||
}
|
||||
|
||||
// 否则返回直连 URL
|
||||
|
||||
Reference in New Issue
Block a user