mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-03-09 12:50:23 -05:00
Merge a8f3795198
into 05c8023a27
This commit is contained in:
commit
0add131f23
5 changed files with 8 additions and 13 deletions
|
@ -21,9 +21,6 @@ def test_compat_passthrough(self):
|
||||||
with self.assertWarns(DeprecationWarning):
|
with self.assertWarns(DeprecationWarning):
|
||||||
_ = compat.compat_basestring
|
_ = compat.compat_basestring
|
||||||
|
|
||||||
with self.assertWarns(DeprecationWarning):
|
|
||||||
_ = compat.WINDOWS_VT_MODE
|
|
||||||
|
|
||||||
self.assertEqual(urllib.request.getproxies, getproxies)
|
self.assertEqual(urllib.request.getproxies, getproxies)
|
||||||
|
|
||||||
with self.assertWarns(DeprecationWarning):
|
with self.assertWarns(DeprecationWarning):
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
from .globals import (
|
from .globals import (
|
||||||
IN_CLI,
|
IN_CLI,
|
||||||
LAZY_EXTRACTORS,
|
LAZY_EXTRACTORS,
|
||||||
|
WINDOWS_VT_MODE,
|
||||||
plugin_ies,
|
plugin_ies,
|
||||||
plugin_ies_overrides,
|
plugin_ies_overrides,
|
||||||
plugin_pps,
|
plugin_pps,
|
||||||
|
@ -4013,8 +4014,7 @@ def get_encoding(stream):
|
||||||
if os.environ.get('TERM', '').lower() == 'dumb':
|
if os.environ.get('TERM', '').lower() == 'dumb':
|
||||||
additional_info.append('dumb')
|
additional_info.append('dumb')
|
||||||
if not supports_terminal_sequences(stream):
|
if not supports_terminal_sequences(stream):
|
||||||
from .utils import WINDOWS_VT_MODE # Must be imported locally
|
additional_info.append('No VT' if WINDOWS_VT_MODE.value is False else 'No ANSI')
|
||||||
additional_info.append('No VT' if WINDOWS_VT_MODE is False else 'No ANSI')
|
|
||||||
if additional_info:
|
if additional_info:
|
||||||
ret = f'{ret} ({",".join(additional_info)})'
|
ret = f'{ret} ({",".join(additional_info)})'
|
||||||
return ret
|
return ret
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
from ..dependencies.Cryptodome import AES as compat_pycrypto_AES # noqa: F401
|
from ..dependencies.Cryptodome import AES as compat_pycrypto_AES # noqa: F401
|
||||||
from ..networking.exceptions import HTTPError as compat_HTTPError
|
from ..networking.exceptions import HTTPError as compat_HTTPError
|
||||||
|
|
||||||
passthrough_module(__name__, '...utils', ('WINDOWS_VT_MODE', 'windows_enable_vt_mode'))
|
passthrough_module(__name__, '...utils', ('windows_enable_vt_mode',))
|
||||||
|
|
||||||
|
|
||||||
# compat_ctypes_WINFUNCTYPE = ctypes.WINFUNCTYPE
|
# compat_ctypes_WINFUNCTYPE = ctypes.WINFUNCTYPE
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import os
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
# Please Note: Due to necessary changes and the complex nature involved in the plugin/globals system,
|
# Please Note: Due to necessary changes and the complex nature involved in the plugin/globals system,
|
||||||
|
@ -28,3 +29,4 @@ def __repr__(self, /):
|
||||||
# Misc
|
# Misc
|
||||||
IN_CLI = Indirect(False)
|
IN_CLI = Indirect(False)
|
||||||
LAZY_EXTRACTORS = Indirect(None) # `False`=force, `None`=disabled, `True`=enabled
|
LAZY_EXTRACTORS = Indirect(None) # `False`=force, `None`=disabled, `True`=enabled
|
||||||
|
WINDOWS_VT_MODE = Indirect(False if os.name == 'nt' else None)
|
||||||
|
|
|
@ -52,7 +52,7 @@
|
||||||
compat_HTMLParseError,
|
compat_HTMLParseError,
|
||||||
)
|
)
|
||||||
from ..dependencies import xattr
|
from ..dependencies import xattr
|
||||||
from ..globals import IN_CLI
|
from ..globals import IN_CLI, WINDOWS_VT_MODE
|
||||||
|
|
||||||
__name__ = __name__.rsplit('.', 1)[0] # noqa: A001: Pretend to be the parent module
|
__name__ = __name__.rsplit('.', 1)[0] # noqa: A001: Pretend to be the parent module
|
||||||
|
|
||||||
|
@ -4763,13 +4763,10 @@ def jwt_decode_hs256(jwt):
|
||||||
return json.loads(base64.urlsafe_b64decode(f'{payload_b64}==='))
|
return json.loads(base64.urlsafe_b64decode(f'{payload_b64}==='))
|
||||||
|
|
||||||
|
|
||||||
WINDOWS_VT_MODE = False if os.name == 'nt' else None
|
|
||||||
|
|
||||||
|
|
||||||
@functools.cache
|
@functools.cache
|
||||||
def supports_terminal_sequences(stream):
|
def supports_terminal_sequences(stream):
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
if not WINDOWS_VT_MODE:
|
if not WINDOWS_VT_MODE.value:
|
||||||
return False
|
return False
|
||||||
elif not os.getenv('TERM'):
|
elif not os.getenv('TERM'):
|
||||||
return False
|
return False
|
||||||
|
@ -4806,8 +4803,7 @@ def windows_enable_vt_mode():
|
||||||
finally:
|
finally:
|
||||||
os.close(handle)
|
os.close(handle)
|
||||||
|
|
||||||
global WINDOWS_VT_MODE
|
WINDOWS_VT_MODE.value = True
|
||||||
WINDOWS_VT_MODE = True
|
|
||||||
supports_terminal_sequences.cache_clear()
|
supports_terminal_sequences.cache_clear()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue