X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2Fjsinterp.py;h=9737f70021d3285a4e8df616467b764de1a91fa2;hb=c1b2a0858cafc3362e5da73b9fb737f18cde4618;hp=4a5a0dbc3fca59e06a268e51c3a0161ede74db70;hpb=6aeb64b67358176f6c29965d0d138be75c2ad972;p=youtube-dl diff --git a/youtube_dl/jsinterp.py b/youtube_dl/jsinterp.py index 4a5a0dbc3..9737f7002 100644 --- a/youtube_dl/jsinterp.py +++ b/youtube_dl/jsinterp.py @@ -131,8 +131,9 @@ class JSInterpreter(object): if variable in local_vars: obj = local_vars[variable] else: - obj = self._objects.setdefault( - variable, self.extract_object(variable)) + if variable not in self._objects: + self._objects[variable] = self.extract_object(variable) + obj = self._objects[variable] if arg_str is None: # Member access @@ -203,7 +204,8 @@ class JSInterpreter(object): argvals = tuple([ int(v) if v.isdigit() else local_vars[v] for v in m.group('args').split(',')]) - self._functions.setdefault(fname, self.extract_function(fname)) + if fname not in self._functions: + self._functions[fname] = self.extract_function(fname) return self._functions[fname](argvals) raise ExtractorError('Unsupported JS expression %r' % expr) @@ -230,7 +232,7 @@ class JSInterpreter(object): def extract_function(self, funcname): func_m = re.search( r'''(?x) - (?:function\s+%s|[{;,]%s\s*=\s*function|var\s+%s\s*=\s*function)\s* + (?:function\s+%s|[{;,]\s*%s\s*=\s*function|var\s+%s\s*=\s*function)\s* \((?P[^)]*)\)\s* \{(?P[^}]+)\}''' % ( re.escape(funcname), re.escape(funcname), re.escape(funcname)),