mirror of
https://github.com/KuekHaoYang/KVideo.git
synced 2026-08-13 15:53:44 +08:00
Update m3u8-utils.ts
This commit is contained in:
@@ -22,13 +22,8 @@ export type AdFilterMode = 'off' | 'keyword' | 'heuristic' | 'aggressive';
|
||||
export function filterM3u8Ad(content: string, baseUrl: string, mode: AdFilterMode = 'heuristic', customKeywords: string[] = []): string {
|
||||
if (!content) return '';
|
||||
|
||||
// 1. Performance: Parse Keywords & Base URL ONLY ONCE
|
||||
// Merge env keywords (build time) with custom keywords (runtime injected)
|
||||
const envKeywordsStr = process.env.NEXT_PUBLIC_AD_KEYWORDS || '';
|
||||
const envKeywords = envKeywordsStr.split(/[\n,]/).map(k => k.trim()).filter(k => k);
|
||||
|
||||
// Combine and deduplicate
|
||||
const keywords = Array.from(new Set([...envKeywords, ...customKeywords]));
|
||||
// Use keywords passed from AdKeywordsWrapper (already loaded from env/file)
|
||||
const keywords = customKeywords;
|
||||
|
||||
const basePath = baseUrl.substring(0, baseUrl.lastIndexOf('/') + 1);
|
||||
let origin = '';
|
||||
|
||||
Reference in New Issue
Block a user