diff --git a/packages/core/src/streams/filterer.ts b/packages/core/src/streams/filterer.ts index 8f5b257a..365fc366 100644 --- a/packages/core/src/streams/filterer.ts +++ b/packages/core/src/streams/filterer.ts @@ -86,7 +86,11 @@ class StreamFilterer { }; const start = Date.now(); - const isRegexAllowed = FeatureControl.isRegexAllowed(this.userData); + const isRegexAllowed = FeatureControl.isRegexAllowed(this.userData, [ + ...(this.userData.excludedRegexPatterns ?? []), + ...(this.userData.requiredRegexPatterns ?? []), + ...(this.userData.includedRegexPatterns ?? []), + ]); let requestedMetadata: TMDBMetadataResponse | undefined; if (this.userData.titleMatching?.enabled && TYPES.includes(type as any)) { diff --git a/packages/core/src/streams/precomputer.ts b/packages/core/src/streams/precomputer.ts index a19ee3d7..e3499347 100644 --- a/packages/core/src/streams/precomputer.ts +++ b/packages/core/src/streams/precomputer.ts @@ -19,8 +19,12 @@ class StreamPrecomputer { public async precompute(streams: ParsedStream[]) { const preferredRegexPatterns = - FeatureControl.isRegexAllowed(this.userData) && - this.userData.preferredRegexPatterns + FeatureControl.isRegexAllowed( + this.userData, + this.userData.preferredRegexPatterns?.map( + (pattern) => pattern.pattern + ) ?? [] + ) && this.userData.preferredRegexPatterns ? await Promise.all( this.userData.preferredRegexPatterns.map(async (pattern) => { return { diff --git a/packages/core/src/utils/feature.ts b/packages/core/src/utils/feature.ts index 38da20f5..bd844286 100644 --- a/packages/core/src/utils/feature.ts +++ b/packages/core/src/utils/feature.ts @@ -66,7 +66,15 @@ export class FeatureControl { return this._allowedRegexPatterns; } - public static isRegexAllowed(userData: UserData) { + public static isRegexAllowed(userData: UserData, regexes?: string[]) { + if (regexes && regexes.length > 0) { + const areAllRegexesAllowed = regexes.every((regex) => + this.allowedRegexPatterns.patterns.includes(regex) + ); + if (areAllRegexesAllowed) { + return true; + } + } switch (this.regexFilterAccess) { case 'trusted': return userData.trusted ?? false;