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