Skip to content

Commit

Permalink
chore(Player): Don't throw an error if nsig extraction fails
Browse files Browse the repository at this point in the history
This is called when an InnerTube instance is created, so throwing here breaks the entire library.
  • Loading branch information
LuanRT committed Jul 30, 2024
1 parent 94a6765 commit 5529a6a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/core/Player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,10 @@ export default class Player {
static extractNSigSourceCode(data: string): string {
const match = data.match(/b=(?:a\.split\(|String\.prototype\.split\.call\(a,)""\).*?\}return (?:b\.join\(|Array\.prototype\.join\.call\(b,)""\)\}/s);

// Don't throw an error here.
if (!match) {
throw new PlayerError('Failed to extract n-token decipher algorithm');
Log.warn(TAG, 'Failed to extract nsig decipher algorithm.');
return 'function descramble_nsig(a) { return a } descramble_nsig(nsig);';
}

return `function descramble_nsig(a) { let ${match[0]} descramble_nsig(nsig)`;
Expand Down

0 comments on commit 5529a6a

Please sign in to comment.