From b7cab99026788d3c9ec7a998dcb949c0f820244f Mon Sep 17 00:00:00 2001 From: mtvpls Date: Sun, 5 Oct 2025 16:43:14 +0800 Subject: [PATCH 1/2] Update page.tsx --- src/app/play/page.tsx | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/app/play/page.tsx b/src/app/play/page.tsx index 99886e2..7068dd2 100644 --- a/src/app/play/page.tsx +++ b/src/app/play/page.tsx @@ -493,23 +493,42 @@ function PlayPageClient() { } }; - // 去广告相关函数 - function filterAdsFromM3U8(m3u8Content: string): string { + function filterAdsFromM3U8(type : string,m3u8Content: string): string { if (!m3u8Content) return ''; // 按行分割M3U8内容 const lines = m3u8Content.split('\n'); const filteredLines = []; + let nextdelete = false for (let i = 0; i < lines.length; i++) { const line = lines[i]; + if (nextdelete){ + nextdelete = false + continue + } + // 只过滤#EXT-X-DISCONTINUITY标识 if (!line.includes('#EXT-X-DISCONTINUITY')) { + + if (type == "ruyi" && ( + line.includes('EXTINF:5.640000') || + line.includes('EXTINF:2.960000') || + line.includes('EXTINF:3.480000') || + line.includes('EXTINF:4.000000') || + line.includes('EXTINF:0.960000') || + line.includes('EXTINF:10.000000') || + line.includes('EXTINF:1.266667') + )){ + nextdelete = true + continue + } + filteredLines.push(line); } } - + return filteredLines.join('\n'); } From 5097a808b17f1cf9e8ad77fc6b9058df90c55aed Mon Sep 17 00:00:00 2001 From: mtvpls Date: Sun, 5 Oct 2025 16:47:29 +0800 Subject: [PATCH 2/2] Update page.tsx --- src/app/play/page.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/play/page.tsx b/src/app/play/page.tsx index 7068dd2..1c78cf7 100644 --- a/src/app/play/page.tsx +++ b/src/app/play/page.tsx @@ -653,7 +653,7 @@ function PlayPageClient() { // 如果是m3u8文件,处理内容以移除广告分段 if (response.data && typeof response.data === 'string') { // 过滤掉广告段 - 实现更精确的广告过滤逻辑 - response.data = filterAdsFromM3U8(response.data); + response.data = filterAdsFromM3U8(currentSourceRef.current,response.data); } return onSuccess(response, stats, context, null); };