mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-13 09:32:12 +00:00
fix(Player): Use global var to find signature algorithm (#953)
* chore: Update jintr to version 3.3.1 * fix(Player): Use global var to find signature algorithm This change allows matching code such as: ``` // "Y" is the global var. r = r[Y[14]](Y[19]); q3[Y[8]](r, 30); q3[Y[8]](r, 65); q3[Y[8]](r, 2); ``` TODO: Maybe consider removing the regex (it's too fragile) and instead use the AST walker, like we already do for `nsig` and the global lookup variable.
This commit is contained in:
8
package-lock.json
generated
8
package-lock.json
generated
@@ -13,7 +13,7 @@
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@bufbuild/protobuf": "^2.0.0",
|
||||
"jintr": "^3.3.0",
|
||||
"jintr": "^3.3.1",
|
||||
"tslib": "^2.5.0",
|
||||
"undici": "^5.19.1"
|
||||
},
|
||||
@@ -6155,9 +6155,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/jintr": {
|
||||
"version": "3.3.0",
|
||||
"resolved": "https://registry.npmjs.org/jintr/-/jintr-3.3.0.tgz",
|
||||
"integrity": "sha512-ZsaajJ4Hr5XR0tSPhOZOTjFhxA0qscKNSOs41NRjx7ZOGwpfdp8NKIBEUtvUPbA37JXyv1sJlgeOOZHjr3h76Q==",
|
||||
"version": "3.3.1",
|
||||
"resolved": "https://registry.npmjs.org/jintr/-/jintr-3.3.1.tgz",
|
||||
"integrity": "sha512-nnOzyhf0SLpbWuZ270Omwbj5LcXUkTcZkVnK8/veJXtSZOiATM5gMZMdmzN75FmTyj+NVgrGaPdH12zIJ24oIA==",
|
||||
"funding": [
|
||||
"https://github.com/sponsors/LuanRT"
|
||||
],
|
||||
|
||||
@@ -103,7 +103,7 @@
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@bufbuild/protobuf": "^2.0.0",
|
||||
"jintr": "^3.3.0",
|
||||
"jintr": "^3.3.1",
|
||||
"tslib": "^2.5.0",
|
||||
"undici": "^5.19.1"
|
||||
},
|
||||
|
||||
@@ -258,7 +258,18 @@ export default class Player {
|
||||
}
|
||||
|
||||
static extractSigSourceCode(data: string, global_variable?: ASTLookupResult): string | undefined {
|
||||
const match = data.match(/function\(([A-Za-z_0-9]+)\)\{([A-Za-z_0-9]+=[A-Za-z_0-9]+\.split\((?:[^)]+)\)(.+?)\.join\((?:[^)]+)\))\}/);
|
||||
// Classic static split/join.
|
||||
const split_join_regex = /function\(([A-Za-z_0-9]+)\)\{([A-Za-z_0-9]+=[A-Za-z_0-9]+\.split\((?:[^)]+)\)(.+?)\.join\((?:[^)]+)\))\}/;
|
||||
|
||||
// Using the global lookup variable.
|
||||
const lookup_var = global_variable?.name?.replace(/[$^\\.*+?()[\]{}|]/g, '\\$&');
|
||||
const lookup_regex = lookup_var
|
||||
? new RegExp(
|
||||
`function\\(([A-Za-z_0-9]+)\\)\\{([A-Za-z_0-9]+=[A-Za-z_0-9]+\\[${lookup_var}\\[\\d+\\]\\]\\([^)]*\\)([\\s\\S]+?)\\[${lookup_var}\\[\\d+\\]\\]\\([^)]*\\))\\}`
|
||||
)
|
||||
: null;
|
||||
|
||||
const match = data.match(split_join_regex) || (lookup_regex ? data.match(lookup_regex) : null);
|
||||
|
||||
if (!match) {
|
||||
Log.warn(TAG, 'Failed to extract signature decipher algorithm.');
|
||||
|
||||
Reference in New Issue
Block a user