mirror of
https://github.com/yt-dlp/ejs.git
synced 2026-06-13 00:32:11 +00:00
Fix sig in player 638ec5c6 (#10)
This commit is contained in:
@@ -22,6 +22,11 @@ export function matchesStructure<T extends ESTree.Node>(
|
||||
// Handle `{ or: [a, b] }`
|
||||
return structure.or.some((node) => matchesStructure(obj, node));
|
||||
}
|
||||
if ("anykey" in structure && Array.isArray(structure.anykey)) {
|
||||
// Handle `{ anykey: [a, b] }`
|
||||
const haystack = Array.isArray(obj) ? obj : Object.values(obj);
|
||||
return structure.anykey.every(value => haystack.some((el) => matchesStructure(el, value)));
|
||||
}
|
||||
for (const [key, value] of Object.entries(structure)) {
|
||||
if (!matchesStructure(obj[key as keyof typeof obj], value)) {
|
||||
return false;
|
||||
|
||||
@@ -82,6 +82,20 @@ const identifier = {
|
||||
type: "FunctionDeclaration",
|
||||
params: [{}, {}, {}],
|
||||
},
|
||||
{
|
||||
type: "VariableDeclaration",
|
||||
declarations: {
|
||||
anykey: [
|
||||
{
|
||||
type: "VariableDeclarator",
|
||||
init: {
|
||||
type: "FunctionExpression",
|
||||
params: [{}, {}, {}],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
} as const;
|
||||
|
||||
@@ -93,14 +107,27 @@ export function extract(
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
const block =
|
||||
node.type === "ExpressionStatement" &&
|
||||
let block: ESTree.BlockStatement | undefined | null;
|
||||
if (node.type === "ExpressionStatement" &&
|
||||
node.expression.type === "AssignmentExpression" &&
|
||||
node.expression.right.type === "FunctionExpression"
|
||||
? node.expression.right.body
|
||||
: node.type === "FunctionDeclaration"
|
||||
? node.body
|
||||
: null;
|
||||
node.expression.right.type === "FunctionExpression") {
|
||||
block = node.expression.right.body;
|
||||
} else if (node.type === "VariableDeclaration") {
|
||||
for (const decl of node.declarations) {
|
||||
if (
|
||||
decl.type === "VariableDeclarator" &&
|
||||
decl.init?.type === "FunctionExpression" &&
|
||||
decl.init?.params.length === 3
|
||||
) {
|
||||
block = decl.init.body;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (node.type === "FunctionDeclaration") {
|
||||
block = node.body;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
const relevantExpression = block?.body.at(-2);
|
||||
if (!matchesStructure(relevantExpression!, logicalExpression)) {
|
||||
return null;
|
||||
|
||||
@@ -253,6 +253,24 @@ export const tests: {
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
// TODO: es6/tv_es6 variants currently fail
|
||||
player: "638ec5c6",
|
||||
variants: ["main", "tcc", "tce", "es5", "tv", "phone", "tablet"],
|
||||
n: [
|
||||
// Synthetic test
|
||||
{ input: "ZdZIqFPQK-Ty8wId", expected: "1qov8-KM-yH" },
|
||||
],
|
||||
sig: [
|
||||
// Synthetic test
|
||||
{
|
||||
input:
|
||||
"gN7a-hudCuAuPH6fByOk1_GNXN0yNMHShjZXS2VOgsEItAJz0tipeavEOmNdYN-wUtcEqD3bCXjc0iyKfAyZxCBGgIARwsSdQfJ2CJtt",
|
||||
expected:
|
||||
"MhudCuAuP-6fByOk1_GNXN7gNHHShjyXS2VOgsEItAJz0tipeav0OmNdYN-wUtcEqD3bCXjc0iyKfAyZxCBGgIARwsSdQfJ2CJtt",
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
export const players = new Map([
|
||||
|
||||
Reference in New Issue
Block a user