Skip to content

Commit

Permalink
fix(Player): Fix extracting the n-token decipher algorithm again (#701)
Browse files Browse the repository at this point in the history
  • Loading branch information
absidue committed Jul 25, 2024
1 parent 090539b commit 3048f70
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions src/core/Player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 3048f70

Please sign in to comment.