Skip to content

Commit

Permalink
Copy LuanRT#682 in base repo to fix nsig issues
Browse files Browse the repository at this point in the history
See LuanRT#682. Original author is
absidue; I did not author this code, I just pulled it in here to test
it.
  • Loading branch information
dylnuge committed Jul 9, 2024
1 parent 1b00e2c commit 4b6b643
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/core/Player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,20 @@ export default class Player {
}

static extractNSigSourceCode(data: string): string {
const sc = `function descramble_nsig(a) { let b=a.split("")${getStringBetweenStrings(data, 'b=a.split("")', '}return b.join("")}')}} return b.join(""); } descramble_nsig(nsig)`;
let sc = getStringBetweenStrings(data, 'b=a.split("")', '}return b.join("")}');

if (!sc)
Log.warn(Player.TAG, 'Failed to extract n-token decipher algorithm');
if (sc)
return `function descramble_nsig(a) { let b=a.split("")${sc}} return b.join(""); } descramble_nsig(nsig)`;

return sc;
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');

return 'function descramble_nsig(a) { return a; } descramble_nsig(nsig)';
}

get url(): string {
Expand All @@ -248,4 +256,4 @@ export default class Player {
static get LIBRARY_VERSION(): number {
return 2;
}
}
}

0 comments on commit 4b6b643

Please sign in to comment.