Compare commits

..

No commits in common. "2389c7cbd30813435c50848a9b276bcfe2a810db" and "d1c6c5c4d618fa950813c0c71aede34a5ac851e9" have entirely different histories.

6 changed files with 18 additions and 32 deletions

View File

@ -516,9 +516,6 @@ class TestJSInterpreter(unittest.TestCase):
jsi = JSInterpreter('function x(){return 42 << NaN}') jsi = JSInterpreter('function x(){return 42 << NaN}')
self.assertEqual(jsi.call_function('x'), 42) self.assertEqual(jsi.call_function('x'), 42)
jsi = JSInterpreter('function x(){return 42 << Infinity}')
self.assertEqual(jsi.call_function('x'), 42)
def test_32066(self): def test_32066(self):
jsi = JSInterpreter("function x(){return Math.pow(3, 5) + new Date('1970-01-01T08:01:42.000+08:00') / 1000 * -239 - -24205;}") jsi = JSInterpreter("function x(){return Math.pow(3, 5) + new Date('1970-01-01T08:01:42.000+08:00') / 1000 * -239 - -24205;}")
self.assertEqual(jsi.call_function('x'), 70) self.assertEqual(jsi.call_function('x'), 70)

View File

@ -143,14 +143,6 @@ _NSIG_TESTS = [
'https://www.youtube.com/s/player/dac945fd/player_ias.vflset/en_US/base.js', 'https://www.youtube.com/s/player/dac945fd/player_ias.vflset/en_US/base.js',
'o8BkRxXhuYsBCWi6RplPdP', '3Lx32v_hmzTm6A', 'o8BkRxXhuYsBCWi6RplPdP', '3Lx32v_hmzTm6A',
), ),
(
'https://www.youtube.com/s/player/6f20102c/player_ias.vflset/en_US/base.js',
'lE8DhoDmKqnmJJ', 'pJTTX6XyJP2BYw',
),
(
'https://www.youtube.com/s/player/cfa9e7cb/player_ias.vflset/en_US/base.js',
'qO0NiMtYQ7TeJnfFG2', 'k9cuJDHNS5O7kQ',
),
] ]

View File

@ -102,7 +102,6 @@ from .utils import (
YoutubeDLCookieProcessor, YoutubeDLCookieProcessor,
YoutubeDLHandler, YoutubeDLHandler,
YoutubeDLRedirectHandler, YoutubeDLRedirectHandler,
ytdl_is_updateable,
) )
from .cache import Cache from .cache import Cache
from .extractor import get_info_extractor, gen_extractor_classes, _LAZY_LOADER from .extractor import get_info_extractor, gen_extractor_classes, _LAZY_LOADER
@ -2374,11 +2373,9 @@ class YoutubeDL(object):
self.get_encoding())) self.get_encoding()))
write_string(encoding_str, encoding=None) write_string(encoding_str, encoding=None)
writeln_debug = lambda *s: self._write_string('[debug] %s\n' % (''.join(s), )) self._write_string('[debug] youtube-dl version ' + __version__ + '\n')
writeln_debug('youtube-dl version ', __version__, (' (single file build)' if ytdl_is_updateable() else ''))
if _LAZY_LOADER: if _LAZY_LOADER:
writeln_debug('Lazy loading extractors enabled') self._write_string('[debug] Lazy loading extractors enabled' + '\n')
try: try:
sp = subprocess.Popen( sp = subprocess.Popen(
['git', 'rev-parse', '--short', 'HEAD'], ['git', 'rev-parse', '--short', 'HEAD'],
@ -2387,7 +2384,7 @@ class YoutubeDL(object):
out, err = process_communicate_or_kill(sp) out, err = process_communicate_or_kill(sp)
out = out.decode().strip() out = out.decode().strip()
if re.match('[0-9a-f]+', out): if re.match('[0-9a-f]+', out):
writeln_debug('Git HEAD: ', out) self._write_string('[debug] Git HEAD: ' + out + '\n')
except Exception: except Exception:
try: try:
sys.exc_clear() sys.exc_clear()
@ -2406,15 +2403,13 @@ class YoutubeDL(object):
except OSError: # We may not have access to the executable except OSError: # We may not have access to the executable
return [] return []
libc = join_nonempty(*libc_ver(), delim=' ') self._write_string('[debug] Python %s (%s %s) - %s (%s%s)\n' % (
writeln_debug('Python %s (%s %s %s) - %s - %s%s' % (
platform.python_version(), platform.python_version(),
python_implementation(), python_implementation(),
platform.machine(),
platform.architecture()[0], platform.architecture()[0],
platform_name(), platform_name(),
OPENSSL_VERSION, OPENSSL_VERSION,
(' - %s' % (libc, )) if libc else '' ', %s' % (join_nonempty(*libc_ver(), delim=' ') or '-'),
)) ))
exe_versions = FFmpegPostProcessor.get_versions(self) exe_versions = FFmpegPostProcessor.get_versions(self)
@ -2427,17 +2422,17 @@ class YoutubeDL(object):
) )
if not exe_str: if not exe_str:
exe_str = 'none' exe_str = 'none'
writeln_debug('exe versions: %s' % (exe_str, )) self._write_string('[debug] exe versions: %s\n' % exe_str)
proxy_map = {} proxy_map = {}
for handler in self._opener.handlers: for handler in self._opener.handlers:
if hasattr(handler, 'proxies'): if hasattr(handler, 'proxies'):
proxy_map.update(handler.proxies) proxy_map.update(handler.proxies)
writeln_debug('Proxy map: ', compat_str(proxy_map)) self._write_string('[debug] Proxy map: ' + compat_str(proxy_map) + '\n')
if self.params.get('call_home', False): if self.params.get('call_home', False):
ipaddr = self.urlopen('https://yt-dl.org/ip').read().decode('utf-8') ipaddr = self.urlopen('https://yt-dl.org/ip').read().decode('utf-8')
writeln_debug('Public IP address: %s' % (ipaddr, )) self._write_string('[debug] Public IP address: %s\n' % ipaddr)
latest_version = self.urlopen( latest_version = self.urlopen(
'https://yt-dl.org/latest/version').read().decode('utf-8') 'https://yt-dl.org/latest/version').read().decode('utf-8')
if version_tuple(latest_version) > version_tuple(__version__): if version_tuple(latest_version) > version_tuple(__version__):

View File

@ -1663,5 +1663,5 @@ def casefold(s):
__all__ = [ __all__ = [
'casefold', casefold
] ]

View File

@ -59,7 +59,7 @@ class ITVBaseIE(InfoExtractor):
@staticmethod @staticmethod
def _vanilla_ua_header(): def _vanilla_ua_header():
return {'User-Agent': 'Mozilla/5.0'} return {'User-agent': 'Mozilla/5.0'}
def _download_webpage_handle(self, url, video_id, *args, **kwargs): def _download_webpage_handle(self, url, video_id, *args, **kwargs):
# specialised to (a) use vanilla UA (b) detect geo-block # specialised to (a) use vanilla UA (b) detect geo-block
@ -69,7 +69,7 @@ class ITVBaseIE(InfoExtractor):
'user_agent' not in params 'user_agent' not in params
and not any(re.match(r'(?i)user-agent\s*:', h) and not any(re.match(r'(?i)user-agent\s*:', h)
for h in (params.get('headers') or [])) for h in (params.get('headers') or []))
and 'User-Agent' not in (kwargs.get('headers') or {})): and 'User-agent' not in (kwargs.get('headers') or {})):
kwargs.setdefault('headers', {}) kwargs.setdefault('headers', {})
kwargs['headers'] = self._vanilla_ua_header() kwargs['headers'] = self._vanilla_ua_header()

View File

@ -2,6 +2,7 @@ from __future__ import unicode_literals
import itertools import itertools
import json import json
import math
import operator import operator
import re import re
@ -51,10 +52,6 @@ def wraps_op(op):
return update_and_rename_wrapper return update_and_rename_wrapper
# NB In principle NaN cannot be checked by membership.
# Here all NaN values are actually this one, so _NaN is _NaN,
# although _NaN != _NaN.
_NaN = float('nan') _NaN = float('nan')
@ -129,8 +126,13 @@ def _js_comp_op(op):
def _js_ternary(cndn, if_true=True, if_false=False): def _js_ternary(cndn, if_true=True, if_false=False):
"""Simulate JS's ternary operator (cndn?if_true:if_false)""" """Simulate JS's ternary operator (cndn?if_true:if_false)"""
if cndn in (False, None, 0, '', JS_Undefined, _NaN): if cndn in (False, None, 0, '', JS_Undefined):
return if_false return if_false
try:
if math.isnan(cndn): # NB: NaN cannot be checked by membership
return if_false
except TypeError:
pass
return if_true return if_true