aboutsummaryrefslogtreecommitdiffstats
path: root/yt_dlp/jsinterp.py
diff options
context:
space:
mode:
authorpukkandan <pukkandan.ytdlp@gmail.com>2022-08-16 06:53:45 +0530
committerpukkandan <pukkandan.ytdlp@gmail.com>2022-08-16 06:53:45 +0530
commit6d3e7424bfe8cfdbd5931a37519ca7faafff642d (patch)
tree78437829e64e48686fa5500345b7661da13d2309 /yt_dlp/jsinterp.py
parent5c6d2ef9d1001508407d7825d731013f3cb99f5f (diff)
downloadhypervideo-pre-6d3e7424bfe8cfdbd5931a37519ca7faafff642d.tar.lz
hypervideo-pre-6d3e7424bfe8cfdbd5931a37519ca7faafff642d.tar.xz
hypervideo-pre-6d3e7424bfe8cfdbd5931a37519ca7faafff642d.zip
[jsinterp] Fix for youtube player c81bbb4a
Diffstat (limited to 'yt_dlp/jsinterp.py')
-rw-r--r--yt_dlp/jsinterp.py30
1 files changed, 15 insertions, 15 deletions
diff --git a/yt_dlp/jsinterp.py b/yt_dlp/jsinterp.py
index 87f141476..47cca1176 100644
--- a/yt_dlp/jsinterp.py
+++ b/yt_dlp/jsinterp.py
@@ -33,19 +33,19 @@ _OPERATORS = { # None => Defined in JSInterpreter._operator
'==': operator.eq,
'!=': operator.ne,
- '<=': operator.le,
- '>=': operator.ge,
- '<': operator.lt,
- '>': operator.gt,
+ '<=': lambda a, b: (a or 0) <= (b or 0),
+ '>=': lambda a, b: (a or 0) >= (b or 0),
+ '<': lambda a, b: (a or 0) < (b or 0),
+ '>': lambda a, b: (a or 0) > (b or 0),
'>>': operator.rshift,
'<<': operator.lshift,
- '+': operator.add,
- '-': operator.sub,
+ '+': lambda a, b: (a or 0) + (b or 0),
+ '-': lambda a, b: (a or 0) - (b or 0),
- '*': operator.mul,
- '/': operator.truediv,
+ '*': lambda a, b: (a or 0) * (b or 0),
+ '/': lambda a, b: (a or 0) / b,
'%': operator.mod,
'**': operator.pow,
@@ -339,11 +339,12 @@ class JSInterpreter:
# Comma separated statements
sub_expressions = list(self._separate(expr))
- expr = sub_expressions.pop().strip() if sub_expressions else ''
- for sub_expr in sub_expressions:
- ret, should_abort = self.interpret_statement(sub_expr, local_vars, allow_recursion)
- if should_abort:
- return ret, True
+ if len(sub_expressions) > 1:
+ for sub_expr in sub_expressions:
+ ret, should_abort = self.interpret_statement(sub_expr, local_vars, allow_recursion)
+ if should_abort:
+ return ret, True
+ return ret, False
for m in re.finditer(rf'''(?x)
(?P<pre_sign>\+\+|--)(?P<var1>{_NAME_RE})|
@@ -422,8 +423,7 @@ class JSInterpreter:
if not separated:
continue
left_val = self.interpret_expression(op.join(separated), local_vars, allow_recursion)
- return self._operator(op, 0 if left_val is None else left_val,
- right_expr, expr, local_vars, allow_recursion), should_return
+ return self._operator(op, left_val, right_expr, expr, local_vars, allow_recursion), should_return
if m and m.group('attribute'):
variable = m.group('var')