diff --git a/src/app/api/emby/image/[token]/[itemId]/route.ts b/src/app/api/emby/image/[token]/[itemId]/route.ts index e588301..41285b7 100644 --- a/src/app/api/emby/image/[token]/[itemId]/route.ts +++ b/src/app/api/emby/image/[token]/[itemId]/route.ts @@ -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 = { diff --git a/src/app/api/emby/play/[token]/[filename]/route.ts b/src/app/api/emby/play/[token]/[filename]/route.ts index 90cb8c6..0d169df 100644 --- a/src/app/api/emby/play/[token]/[filename]/route.ts +++ b/src/app/api/emby/play/[token]/[filename]/route.ts @@ -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 { diff --git a/src/lib/emby.client.ts b/src/lib/emby.client.ts index 344b6e5..13ef95a 100644 --- a/src/lib/emby.client.ts +++ b/src/lib/emby.client.ts @@ -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