diff options
author | dirkf <fieldhouse@gmx.net> | 2025-03-25 22:16:19 +0000 |
---|---|---|
committer | dirkf <fieldhouse@gmx.net> | 2025-03-25 22:35:06 +0000 |
commit | c55dbf48384f9721ae8eb07fd914ccf2d3c823b0 (patch) | |
tree | 7a0346c01407d2e813de74c397bb0e57cc0f9c94 /youtube_dl/jsinterp.py | |
parent | 087d8652302270764bf9679c7621db0d20ad5572 (diff) |
[YouTube] Update signature extraction for players `643afba4`, `363db69b`
Diffstat (limited to 'youtube_dl/jsinterp.py')
-rw-r--r-- | youtube_dl/jsinterp.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/youtube_dl/jsinterp.py b/youtube_dl/jsinterp.py index a6d4f8e75..186d2594a 100644 --- a/youtube_dl/jsinterp.py +++ b/youtube_dl/jsinterp.py @@ -1368,19 +1368,21 @@ class JSInterpreter(object): code, _ = self._separate_at_paren(func_m.group('code')) # refine the match return self.build_arglist(func_m.group('args')), code - def extract_function(self, funcname): + def extract_function(self, funcname, *global_stack): return function_with_repr( - self.extract_function_from_code(*self.extract_function_code(funcname)), + self.extract_function_from_code(*itertools.chain( + self.extract_function_code(funcname), global_stack)), 'F<%s>' % (funcname,)) def extract_function_from_code(self, argnames, code, *global_stack): local_vars = {} + start = None while True: - mobj = re.search(r'function\((?P<args>[^)]*)\)\s*{', code) + mobj = re.search(r'function\((?P<args>[^)]*)\)\s*{', code[start:]) if mobj is None: break - start, body_start = mobj.span() + start, body_start = ((start or 0) + x for x in mobj.span()) body, remaining = self._separate_at_paren(code[body_start - 1:]) name = self._named_object(local_vars, self.extract_function_from_code( [x.strip() for x in mobj.group('args').split(',')], |