Upgraded youtube_download plugin

This commit is contained in:
2026-05-26 20:50:58 -05:00
parent d55bc3ae97
commit 38ea00ec8f
87 changed files with 3385 additions and 1424 deletions

View File

@@ -18,6 +18,14 @@ from .utils import (
)
def int_to_int32(n):
"""Converts an integer to a signed 32-bit integer"""
n &= 0xFFFFFFFF
if n & 0x80000000:
return n - 0x100000000
return n
def _js_bit_op(op):
def zeroise(x):
if x in (None, JS_Undefined):
@@ -28,7 +36,7 @@ def _js_bit_op(op):
return int(float(x))
def wrapped(a, b):
return op(zeroise(a), zeroise(b)) & 0xffffffff
return int_to_int32(op(int_to_int32(zeroise(a)), int_to_int32(zeroise(b))))
return wrapped
@@ -368,6 +376,10 @@ class JSInterpreter:
if not _OPERATORS.get(op):
return right_val
# TODO: This is only correct for str+str and str+number; fix for str+array, str+object, etc
if op == '+' and (isinstance(left_val, str) or isinstance(right_val, str)):
return f'{left_val}{right_val}'
try:
return _OPERATORS[op](left_val, right_val)
except Exception as e:
@@ -377,7 +389,7 @@ class JSInterpreter:
if idx == 'length':
return len(obj)
try:
return obj[int(idx)] if isinstance(obj, list) else obj[idx]
return obj[int(idx)] if isinstance(obj, list) else obj[str(idx)]
except Exception as e:
if allow_undefined:
return JS_Undefined