summaryrefslogtreecommitdiffstats
path: root/yt_dlp/jsinterp.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-05 09:06:59 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-05 09:06:59 +0000
commit3412579dfc725c8e07e28b2ddc7a8f45513a4cb6 (patch)
tree341608e912c7fbf4f9d043857d5bd2a49912e15d /yt_dlp/jsinterp.py
parentAdding upstream version 2024.07.07. (diff)
downloadyt-dlp-3412579dfc725c8e07e28b2ddc7a8f45513a4cb6.tar.xz
yt-dlp-3412579dfc725c8e07e28b2ddc7a8f45513a4cb6.zip
Adding upstream version 2024.07.09.upstream/2024.07.09
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'yt_dlp/jsinterp.py')
-rw-r--r--yt_dlp/jsinterp.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/yt_dlp/jsinterp.py b/yt_dlp/jsinterp.py
index a0f3289..851d4dc 100644
--- a/yt_dlp/jsinterp.py
+++ b/yt_dlp/jsinterp.py
@@ -636,6 +636,8 @@ class JSInterpreter:
raise self.Exception(f'{member} {msg}', expr)
def eval_method():
+ nonlocal member
+
if (variable, member) == ('console', 'debug'):
if Debugger.ENABLED:
Debugger.write(self.interpret_expression(f'[{arg_str}]', local_vars, allow_recursion))
@@ -644,6 +646,7 @@ class JSInterpreter:
types = {
'String': str,
'Math': float,
+ 'Array': list,
}
obj = local_vars.get(variable, types.get(variable, NO_DEFAULT))
if obj is NO_DEFAULT:
@@ -667,6 +670,21 @@ class JSInterpreter:
self.interpret_expression(v, local_vars, allow_recursion)
for v in self._separate(arg_str)]
+ # Fixup prototype call
+ if isinstance(obj, type) and member.startswith('prototype.'):
+ new_member, _, func_prototype = member.partition('.')[2].partition('.')
+ assertion(argvals, 'takes one or more arguments')
+ assertion(isinstance(argvals[0], obj), f'needs binding to type {obj}')
+ if func_prototype == 'call':
+ obj, *argvals = argvals
+ elif func_prototype == 'apply':
+ assertion(len(argvals) == 2, 'takes two arguments')
+ obj, argvals = argvals
+ assertion(isinstance(argvals, list), 'second argument needs to be a list')
+ else:
+ raise self.Exception(f'Unsupported Function method {func_prototype}', expr)
+ member = new_member
+
if obj is str:
if member == 'fromCharCode':
assertion(argvals, 'takes one or more arguments')