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'); }