超分跨域增强

This commit is contained in:
mtvpls
2026-07-30 19:22:29 +08:00
parent 33193d9ae1
commit fa5f4a6727
2 changed files with 47 additions and 1 deletions
+7 -1
View File
@@ -40,6 +40,10 @@ export async function generateMetadata(): Promise<Metadata> {
title: siteName, title: siteName,
description: '影视聚合', description: '影视聚合',
manifest: '/manifest.json', manifest: '/manifest.json',
// 供配套浏览器扩展(moontvplus-extension)识别本站部署(勿删)
other: {
'moontvplus-site': '1',
},
// iOS 添加到主屏幕:沉浸式状态栏(需配合 viewport-fit=cover + 顶部 safe-area // iOS 添加到主屏幕:沉浸式状态栏(需配合 viewport-fit=cover + 顶部 safe-area
appleWebApp: { appleWebApp: {
capable: true, capable: true,
@@ -336,8 +340,10 @@ export default async function RootLayout({
}; };
return ( return (
<html lang='zh-CN' suppressHydrationWarning> <html lang='zh-CN' data-moontvplus='1' suppressHydrationWarning>
<head> <head>
{/* 配套 moontvplus-extension 识别指纹;仅本项目部署站应带此标记 */}
<meta name='moontvplus-site' content='1' />
<meta <meta
name='viewport' name='viewport'
content='width=device-width, initial-scale=1.0, viewport-fit=cover' content='width=device-width, initial-scale=1.0, viewport-fit=cover'
+40
View File
@@ -741,6 +741,32 @@ function PlayPageClient() {
); );
}; };
/** 私人影库类源:配合 moontvplus-extension 跨域媒体模块,供 Anime4K 等读帧 */
const needsPrivateSourceCrossOrigin = (source?: string | null) => {
if (!source) return false;
return (
source === 'openlist' ||
source === 'xiaoya' ||
source === 'emby' ||
source.startsWith('emby_')
);
};
const applyVideoCrossOrigin = (
video: HTMLVideoElement | null,
source?: string | null
) => {
if (!video) return;
if (needsPrivateSourceCrossOrigin(source ?? currentSourceRef.current)) {
if (video.crossOrigin !== 'anonymous') {
video.crossOrigin = 'anonymous';
}
} else if (video.crossOrigin) {
// 切回普通源时去掉,避免无 CORS 的 CDN 在 CORS 模式下播挂
video.crossOrigin = null;
}
};
const isM3u8LikeUrl = (url?: string) => { const isM3u8LikeUrl = (url?: string) => {
if (!url) return false; if (!url) return false;
const normalizedUrl = url.toLowerCase(); const normalizedUrl = url.toLowerCase();
@@ -3785,6 +3811,9 @@ function PlayPageClient() {
// 使用 property 方式也设置一次,确保兼容性 // 使用 property 方式也设置一次,确保兼容性
(video as any).playsInline = true; (video as any).playsInline = true;
(video as any).webkitPlaysInline = true; (video as any).webkitPlaysInline = true;
// openlist/emby/xiaoyaCORS 模式加载,需配套「moontvplus 扩展」注入 ACAO 后 Anime4K 才能读帧
applyVideoCrossOrigin(video, currentSourceRef.current);
}; };
// Wake Lock 相关函数 // Wake Lock 相关函数
@@ -6838,6 +6867,13 @@ function PlayPageClient() {
} else { } else {
artPlayerRef.current.option.type = ''; artPlayerRef.current.option.type = '';
} }
// switch 前先对齐 crossOrigin,避免私人影库直链以非 CORS 模式缓存后无法超分
if (artPlayerRef.current?.video) {
applyVideoCrossOrigin(
artPlayerRef.current.video as HTMLVideoElement,
currentSourceRef.current
);
}
artPlayerRef.current.switch = videoUrl; artPlayerRef.current.switch = videoUrl;
artPlayerRef.current.title = `${videoTitle} - ${playerEpisodeLabel}`; artPlayerRef.current.title = `${videoTitle} - ${playerEpisodeLabel}`;
artPlayerRef.current.poster = videoCover; artPlayerRef.current.poster = videoCover;
@@ -7078,6 +7114,10 @@ function PlayPageClient() {
playsInline: true, playsInline: true,
'webkit-playsinline': 'true', 'webkit-playsinline': 'true',
referrerpolicy: 'no-referrer', referrerpolicy: 'no-referrer',
// 私人影库跨域直链:配合同级 moontvplus-extension 注入 ACAO,供 Anime4K 读帧
...(needsPrivateSourceCrossOrigin(currentSourceRef.current)
? { crossOrigin: 'anonymous' }
: {}),
} as any, } as any,
// HLS 支持配置 // HLS 支持配置
customType: { customType: {