From 88b35ff911a999e0b479417237010c305114ba08 Mon Sep 17 00:00:00 2001 From: bashonly <88596187+bashonly@users.noreply.github.com> Date: Thu, 29 Jan 2026 10:47:00 -0600 Subject: [PATCH] [ie/youtube] Update ejs to 0.4.0 (#15747) Authored by: bashonly --- Makefile | 6 +- pyproject.toml | 2 +- test/test_jsc/test_ejs_integration.py | 15 ++++ .../youtube/jsc/_builtin/vendor/_info.py | 6 +- .../jsc/_builtin/vendor/yt.solver.core.js | 79 ++++++++++++++++--- 5 files changed, 88 insertions(+), 20 deletions(-) diff --git a/Makefile b/Makefile index 134408d58d..11b32ab25c 100644 --- a/Makefile +++ b/Makefile @@ -202,9 +202,9 @@ CONTRIBUTORS: Changelog.md # The following EJS_-prefixed variables are auto-generated by devscripts/update_ejs.py # DO NOT EDIT! -EJS_VERSION = 0.3.2 -EJS_WHEEL_NAME = yt_dlp_ejs-0.3.2-py3-none-any.whl -EJS_WHEEL_HASH = sha256:f2dc6b3d1b909af1f13e021621b0af048056fca5fb07c4db6aa9bbb37a4f66a9 +EJS_VERSION = 0.4.0 +EJS_WHEEL_NAME = yt_dlp_ejs-0.4.0-py3-none-any.whl +EJS_WHEEL_HASH = sha256:19278cff397b243074df46342bb7616c404296aeaff01986b62b4e21823b0b9c EJS_PY_FOLDERS = yt_dlp_ejs yt_dlp_ejs/yt yt_dlp_ejs/yt/solver EJS_PY_FILES = yt_dlp_ejs/__init__.py yt_dlp_ejs/_version.py yt_dlp_ejs/yt/__init__.py yt_dlp_ejs/yt/solver/__init__.py EJS_JS_FOLDERS = yt_dlp_ejs/yt/solver diff --git a/pyproject.toml b/pyproject.toml index f29b3cba81..b5642fddc9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -55,7 +55,7 @@ default = [ "requests>=2.32.2,<3", "urllib3>=2.0.2,<3", "websockets>=13.0", - "yt-dlp-ejs==0.3.2", + "yt-dlp-ejs==0.4.0", ] curl-cffi = [ "curl-cffi>=0.5.10,!=0.6.*,!=0.7.*,!=0.8.*,!=0.9.*,<0.15; implementation_name=='cpython'", diff --git a/test/test_jsc/test_ejs_integration.py b/test/test_jsc/test_ejs_integration.py index 7984810794..f4c04a58c7 100644 --- a/test/test_jsc/test_ejs_integration.py +++ b/test/test_jsc/test_ejs_integration.py @@ -88,6 +88,21 @@ CHALLENGES: list[Challenge] = [ 'gN7a-hudCuAuPH6fByOk1_GNXN0yNMHShjZXS2VOgsEItAJz0tipeavEOmNdYN-wUtcEqD3bCXjc0iyKfAyZxCBGgIARwsSdQfJ2CJtt': 'MhudCuAuP-6fByOk1_GNXN7gNHHShjyXS2VOgsEItAJz0tipeav0OmNdYN-wUtcEqD3bCXjc0iyKfAyZxCBGgIARwsSdQfJ2CJtt', }), + # c1c87fb0: tce variant broke sig solving; n and main variant are added only for regression testing + Challenge('c1c87fb0', Variant.main, JsChallengeType.N, { + 'ZdZIqFPQK-Ty8wId': 'jCHBK5GuAFNa2', + }), + Challenge('c1c87fb0', Variant.main, JsChallengeType.SIG, { + 'gN7a-hudCuAuPH6fByOk1_GNXN0yNMHShjZXS2VOgsEItAJz0tipeavEOmNdYN-wUtcEqD3bCXjc0iyKfAyZxCBGgIARwsSdQfJ2CJtt': + 'ttJC2JfQdSswRAIgGBCxZyAfKyi0cjXCb3DqEctUw-NYdNmOEvaepit0zJAtIEsgOV2SXZjhSHMNy0NXNGa1kOyBf6HPuAuCduh-_', + }), + Challenge('c1c87fb0', Variant.tce, JsChallengeType.N, { + 'ZdZIqFPQK-Ty8wId': 'jCHBK5GuAFNa2', + }), + Challenge('c1c87fb0', Variant.tce, JsChallengeType.SIG, { + 'gN7a-hudCuAuPH6fByOk1_GNXN0yNMHShjZXS2VOgsEItAJz0tipeavEOmNdYN-wUtcEqD3bCXjc0iyKfAyZxCBGgIARwsSdQfJ2CJtt': + 'ttJC2JfQdSswRAIgGBCxZyAfKyi0cjXCb3DqEctUw-NYdNmOEvaepit0zJAtIEsgOV2SXZjhSHMNy0NXNGa1kOyBf6HPuAuCduh-_', + }), ] requests: list[JsChallengeRequest] = [] diff --git a/yt_dlp/extractor/youtube/jsc/_builtin/vendor/_info.py b/yt_dlp/extractor/youtube/jsc/_builtin/vendor/_info.py index 5e42ce3e50..14c867c86f 100644 --- a/yt_dlp/extractor/youtube/jsc/_builtin/vendor/_info.py +++ b/yt_dlp/extractor/youtube/jsc/_builtin/vendor/_info.py @@ -1,10 +1,10 @@ # This file is generated by devscripts/update_ejs.py. DO NOT MODIFY! -VERSION = '0.3.2' +VERSION = '0.4.0' HASHES = { 'yt.solver.bun.lib.js': '6ff45e94de9f0ea936a183c48173cfa9ce526ee4b7544cd556428427c1dd53c8073ef0174e79b320252bf0e7c64b0032cc1cf9c4358f3fda59033b7caa01c241', - 'yt.solver.core.js': '0cd96b2d3f319dfa62cae689efa7d930ef1706e95f5921794db5089b2262957ec0a17d73938d8975ea35d0309cbfb4c8e4418d5e219837215eee242890c8b64d', - 'yt.solver.core.min.js': '370d627703002b4a73b10027702734a3de9484f6b56b739942be1dc2b60fee49dee2aa86ed117d1c8ae1ac55181d326481f1fe2e2e8d5211154d48e2a55dac51', + 'yt.solver.core.js': '05964b458d92a65d4fb7a90bcb5921c9fed2370f4e4f2f25badb41f28aff9069e0b3c4e5bf1baf2d3021787b67fc6093cefa44de30cffdc6f9fb25532484003b', + 'yt.solver.core.min.js': '0cd3c0b37e095d3cca99443b58fe03980ac3bf2e777c2485c23e1f6052b5ede9f07c7f1c79a9c3af3258ea91a228f099741e7eb07b53125b5dcc84bb4c0054f3', 'yt.solver.deno.lib.js': '9c8ee3ab6c23e443a5a951e3ac73c6b8c1c8fb34335e7058a07bf99d349be5573611de00536dcd03ecd3cf34014c4e9b536081de37af3637c5390c6a6fd6a0f0', 'yt.solver.lib.js': '1ee3753a8222fc855f5c39db30a9ccbb7967dbe1fb810e86dc9a89aa073a0907f294c720e9b65427d560a35aa1ce6af19ef854d9126a05ca00afe03f72047733', 'yt.solver.lib.min.js': '8420c259ad16e99ce004e4651ac1bcabb53b4457bf5668a97a9359be9a998a789fee8ab124ee17f91a2ea8fd84e0f2b2fc8eabcaf0b16a186ba734cf422ad053', diff --git a/yt_dlp/extractor/youtube/jsc/_builtin/vendor/yt.solver.core.js b/yt_dlp/extractor/youtube/jsc/_builtin/vendor/yt.solver.core.js index 1cfa0d6a6e..ee167fe163 100644 --- a/yt_dlp/extractor/youtube/jsc/_builtin/vendor/yt.solver.core.js +++ b/yt_dlp/extractor/youtube/jsc/_builtin/vendor/yt.solver.core.js @@ -60,6 +60,26 @@ var jsc = (function (meriyah, astring) { } return value; } + const nsigExpression = { + type: 'VariableDeclaration', + kind: 'var', + declarations: [ + { + type: 'VariableDeclarator', + init: { + type: 'CallExpression', + callee: { type: 'Identifier' }, + arguments: [ + { type: 'Literal' }, + { + type: 'CallExpression', + callee: { type: 'Identifier', name: 'decodeURIComponent' }, + }, + ], + }, + }, + ], + }; const logicalExpression = { type: 'ExpressionStatement', expression: { @@ -186,24 +206,57 @@ var jsc = (function (meriyah, astring) { 'call', (_8) => _8(-2), ]); - if (!matchesStructure(relevantExpression, logicalExpression)) { - return null; - } - if ( + let call = null; + if (matchesStructure(relevantExpression, logicalExpression)) { + if ( + _optionalChain$2([ + relevantExpression, + 'optionalAccess', + (_9) => _9.type, + ]) !== 'ExpressionStatement' || + relevantExpression.expression.type !== 'LogicalExpression' || + relevantExpression.expression.right.type !== 'SequenceExpression' || + relevantExpression.expression.right.expressions[0].type !== + 'AssignmentExpression' || + relevantExpression.expression.right.expressions[0].right.type !== + 'CallExpression' + ) { + return null; + } + call = relevantExpression.expression.right.expressions[0].right; + } else if ( _optionalChain$2([ relevantExpression, 'optionalAccess', - (_9) => _9.type, - ]) !== 'ExpressionStatement' || - relevantExpression.expression.type !== 'LogicalExpression' || - relevantExpression.expression.right.type !== 'SequenceExpression' || - relevantExpression.expression.right.expressions[0].type !== - 'AssignmentExpression' + (_10) => _10.type, + ]) === 'IfStatement' && + relevantExpression.consequent.type === 'BlockStatement' ) { - return null; + for (const n of relevantExpression.consequent.body) { + if (!matchesStructure(n, nsigExpression)) { + continue; + } + if ( + n.type !== 'VariableDeclaration' || + _optionalChain$2([ + n, + 'access', + (_11) => _11.declarations, + 'access', + (_12) => _12[0], + 'access', + (_13) => _13.init, + 'optionalAccess', + (_14) => _14.type, + ]) !== 'CallExpression' + ) { + continue; + } + call = n.declarations[0].init; + break; + } } - const call = relevantExpression.expression.right.expressions[0].right; - if (call.type !== 'CallExpression' || call.callee.type !== 'Identifier') { + if (call === null) { return null; } return {