From 004a07f4edf2edbfe04bcc61f395dac84e2365fa Mon Sep 17 00:00:00 2001 From: dirkf Date: Thu, 6 Feb 2025 20:44:23 +0000 Subject: [PATCH] [JSInterp] Fix bit-shift coercion for player 9c6dfc4a --- test/test_jsinterp.py | 4 ++++ test/test_youtube_signature.py | 4 ++++ youtube_dl/compat.py | 5 +++++ 3 files changed, 13 insertions(+) diff --git a/test/test_jsinterp.py b/test/test_jsinterp.py index 12e7b9b9485..6c34bc89620 100644 --- a/test/test_jsinterp.py +++ b/test/test_jsinterp.py @@ -459,6 +459,10 @@ def test_bitwise_operators_typecast(self): self._test('function f(){return undefined >> 5}', 0) self._test('function f(){return 42 << NaN}', 42) self._test('function f(){return 42 << Infinity}', 42) + self._test('function f(){return 0.0 << null}', 0) + self._test('function f(){return NaN << 42}', 0) + self._test('function f(){return "21.9" << 1}', 42) + self._test('function f(){return 21 << 4294967297}', 42) def test_negative(self): self._test('function f(){return 2 * -2.0 ;}', -4) diff --git a/test/test_youtube_signature.py b/test/test_youtube_signature.py index fcbc9d7a813..67ef75fdede 100644 --- a/test/test_youtube_signature.py +++ b/test/test_youtube_signature.py @@ -219,6 +219,10 @@ 'https://www.youtube.com/s/player/2f1832d2/player_ias.vflset/en_US/base.js', 'YWt1qdbe8SAfkoPHW5d', 'RrRjWQOJmBiP', ), + ( + 'https://www.youtube.com/s/player/9c6dfc4a/player_ias.vflset/en_US/base.js', + 'jbu7ylIosQHyJyJV', 'uwI0ESiynAmhNg', + ), ] diff --git a/youtube_dl/compat.py b/youtube_dl/compat.py index c621f747604..26b655fb6a5 100644 --- a/youtube_dl/compat.py +++ b/youtube_dl/compat.py @@ -3116,17 +3116,21 @@ def compat_kwargs(kwargs): compat_kwargs = lambda kwargs: kwargs +# compat_numeric_types try: compat_numeric_types = (int, float, long, complex) except NameError: # Python 3 compat_numeric_types = (int, float, complex) +# compat_integer_types try: compat_integer_types = (int, long) except NameError: # Python 3 compat_integer_types = (int, ) +# compat_int +compat_int = compat_integer_types[-1] if sys.version_info < (2, 7): def compat_socket_create_connection(address, timeout, source_address=None): @@ -3532,6 +3536,7 @@ def compat_datetime_timedelta_total_seconds(td): 'compat_http_client', 'compat_http_server', 'compat_input', + 'compat_int', 'compat_integer_types', 'compat_itertools_count', 'compat_itertools_zip_longest',