From 41b23415b4df6e85e41cc829b20b49f53797d081 Mon Sep 17 00:00:00 2001 From: absidue <48293849+absidue@users.noreply.github.com> Date: Thu, 25 Jul 2024 14:48:40 +0200 Subject: [PATCH] fix(Player): Fix extracting the n-token decipher algorithm again --- src/core/Player.ts | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/core/Player.ts b/src/core/Player.ts index dd7f5731b..ffbb80d6b 100644 --- a/src/core/Player.ts +++ b/src/core/Player.ts @@ -220,20 +220,13 @@ export default class Player { } static extractNSigSourceCode(data: string): string { - let sc = getStringBetweenStrings(data, 'b=a.split("")', '}return b.join("")}'); + const match = data.match(/b=(?:a\.split\(|String\.prototype\.split\.call\(a,)""\).*?\}return (?:b\.join\(|Array\.prototype\.join\.call\(b,)""\)\}/s); - if (sc) - return `function descramble_nsig(a) { let b=a.split("")${sc}} return b.join(""); } descramble_nsig(nsig)`; - - sc = getStringBetweenStrings(data, 'b=String.prototype.split.call(a,"")', '}return Array.prototype.join.call(b,"")}'); - - if (sc) - return `function descramble_nsig(a) { let b=String.prototype.split.call(a, "")${sc}} return Array.prototype.join.call(b, ""); } descramble_nsig(nsig)`; - - // We really should throw an error here to avoid errors later, returning a pass-through function for backwards-compatibility - Log.warn(TAG, 'Failed to extract n-token decipher algorithm'); + if (!match) { + throw new PlayerError('Failed to extract n-token decipher algorithm'); + } - return 'function descramble_nsig(a) { return a; } descramble_nsig(nsig)'; + return `function descramble_nsig(a) { let ${match[0]} descramble_nsig(nsig)`; } get url(): string {