diff options
author | dirkf <fieldhouse@gmx.net> | 2021-11-27 03:18:29 +0000 |
---|---|---|
committer | dirkf <fieldhouse@gmx.net> | 2022-01-30 00:05:54 +0000 |
commit | 9d142109f445ea247e476cfc0e0ca134f6ebb802 (patch) | |
tree | 5efbd1334584af73b4945305c05cf285ee03ba5c /youtube_dl/jsinterp.py | |
parent | 1ca673bd98cc5bbfa76d00ac84ad5f6c1376db01 (diff) | |
download | youtube-dl-9d142109f445ea247e476cfc0e0ca134f6ebb802.tar.xz |
Back-port test_youtube_signature.py from yt-dlp and fix JSInterp accordingly
Diffstat (limited to 'youtube_dl/jsinterp.py')
-rw-r--r-- | youtube_dl/jsinterp.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/youtube_dl/jsinterp.py b/youtube_dl/jsinterp.py index c75cf45b9..a2306557b 100644 --- a/youtube_dl/jsinterp.py +++ b/youtube_dl/jsinterp.py @@ -9,7 +9,8 @@ from .utils import ( remove_quotes, ) from .compat import ( - compat_collections_abc + compat_collections_abc, + compat_str, ) MutableMapping = compat_collections_abc.MutableMapping @@ -372,7 +373,7 @@ class JSInterpreter(object): # nonlocal member member = nl.member if variable == 'String': - obj = str + obj = compat_str elif variable in local_vars: obj = local_vars[variable] else: @@ -391,7 +392,7 @@ class JSInterpreter(object): self.interpret_expression(v, local_vars, allow_recursion) for v in self._separate(arg_str)] - if obj == str: + if obj == compat_str: if member == 'fromCharCode': assertion(argvals, 'takes one or more arguments') return ''.join(map(chr, argvals)) @@ -533,7 +534,7 @@ class JSInterpreter(object): name = self._named_object( local_vars, self.extract_function_from_code( - [str.strip(x) for x in mobj.group('args').split(',')], + [x.strip() for x in mobj.group('args').split(',')], body, local_vars, *global_stack)) code = code[:start] + name + remaining return self.build_function(argnames, code, local_vars, *global_stack) |