电视直播放行mp4

This commit is contained in:
mtvpls
2026-03-03 12:08:38 +08:00
parent 4f87e99f52
commit 4da312e8c7
3 changed files with 13 additions and 12 deletions
+5 -5
View File
@@ -92,7 +92,7 @@ export async function GET(
if (ac === 'detail') {
return await handleDetailBySearch(client, wd, requestToken, embyKey, request);
}
return await handleSearch(client, wd);
return await handleSearch(client, wd, requestToken);
} else if (ids || ac === 'detail') {
// 详情模式
if (!ids) {
@@ -109,7 +109,7 @@ export async function GET(
return await handleDetail(client, ids, requestToken, embyKey, request);
} else {
// 列表模式
return await handleSearch(client, '');
return await handleSearch(client, '', requestToken);
}
} catch (error) {
console.error('[Emby CMS Proxy] 错误:', error);
@@ -128,7 +128,7 @@ export async function GET(
/**
* 处理搜索请求
*/
async function handleSearch(client: EmbyClient, query: string) {
async function handleSearch(client: EmbyClient, query: string, token: string) {
const result = await client.getItems({
searchTerm: query || undefined,
IncludeItemTypes: 'Movie,Series',
@@ -140,7 +140,7 @@ async function handleSearch(client: EmbyClient, query: string) {
const list = result.Items.map((item) => ({
vod_id: item.Id,
vod_name: item.Name,
vod_pic: client.getImageUrl(item.Id, 'Primary', undefined, requestToken),
vod_pic: client.getImageUrl(item.Id, 'Primary', undefined, token),
vod_remarks: item.Type === 'Movie' ? '电影' : '剧集',
vod_year: item.ProductionYear?.toString() || '',
vod_content: item.Overview || '',
@@ -247,7 +247,7 @@ async function handleDetail(
{
vod_id: item.Id,
vod_name: item.Name,
vod_pic: client.getImageUrl(item.Id, 'Primary', undefined, requestToken),
vod_pic: client.getImageUrl(item.Id, 'Primary', undefined, token),
vod_remarks: item.Type === 'Movie' ? '电影' : '剧集',
vod_year: item.ProductionYear?.toString() || '',
vod_content: item.Overview || '',
+3 -3
View File
@@ -1485,8 +1485,8 @@ function LivePageClient() {
return;
}
// 如果不是 m3u8 或 flv 类型,设置不支持的类型并返回
if (type !== 'm3u8' && type !== 'flv') {
// 如果不是 m3u8、flv 或 mp4 类型,设置不支持的类型并返回
if (type !== 'm3u8' && type !== 'flv' && type !== 'mp4') {
setUnsupportedType(type);
setIsVideoLoading(false);
return;
@@ -1496,7 +1496,7 @@ function LivePageClient() {
setUnsupportedType(null);
const customType = { m3u8: m3u8Loader, flv: flvLoader };
const targetUrl = type === 'flv'
const targetUrl = (type === 'flv' || type === 'mp4')
? videoUrl
: `/api/proxy/m3u8?url=${encodeURIComponent(videoUrl)}&moontv-source=${currentSourceRef.current?.key || ''}`;
try {
+5 -4
View File
@@ -3,7 +3,7 @@ import { getAuthInfoFromCookie } from './auth';
/**
* 获取用于代理的 token
* 优先级:全局 token > 用户 token > null
* 优先级:全局 token > 用户 token(从 cookie 获取)> null
*/
export async function getProxyToken(request?: NextRequest): Promise<string | null> {
// 1. 尝试获取全局 token
@@ -18,9 +18,10 @@ export async function getProxyToken(request?: NextRequest): Promise<string | nul
if (authInfo && authInfo.username) {
try {
const { db } = await import('./db');
const userInfo = await db.getUserInfoV2(authInfo.username);
if (userInfo && userInfo.tvboxToken && !userInfo.banned) {
return userInfo.tvboxToken;
// 通过用户名获取用户的 tvbox token
const userToken = await db.getTvboxSubscribeToken(authInfo.username);
if (userToken) {
return userToken;
}
} catch (error) {
// 忽略错误,继续