mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-27 15:16:52 +01:00
parent
e9df3d42c4
commit
f079514957
@ -586,7 +586,6 @@ def __init__(self, params=None, auto_init=True):
|
|||||||
self._playlist_urls = set()
|
self._playlist_urls = set()
|
||||||
self.cache = Cache(self)
|
self.cache = Cache(self)
|
||||||
|
|
||||||
windows_enable_vt_mode()
|
|
||||||
stdout = sys.stderr if self.params.get('logtostderr') else sys.stdout
|
stdout = sys.stderr if self.params.get('logtostderr') else sys.stdout
|
||||||
self._out_files = Namespace(
|
self._out_files = Namespace(
|
||||||
out=stdout,
|
out=stdout,
|
||||||
@ -595,6 +594,12 @@ def __init__(self, params=None, auto_init=True):
|
|||||||
console=None if compat_os_name == 'nt' else next(
|
console=None if compat_os_name == 'nt' else next(
|
||||||
filter(supports_terminal_sequences, (sys.stderr, sys.stdout)), None)
|
filter(supports_terminal_sequences, (sys.stderr, sys.stdout)), None)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
try:
|
||||||
|
windows_enable_vt_mode()
|
||||||
|
except Exception as e:
|
||||||
|
self.write_debug(f'Failed to enable VT mode: {e}')
|
||||||
|
|
||||||
self._allow_colors = Namespace(**{
|
self._allow_colors = Namespace(**{
|
||||||
type_: not self.params.get('no_color') and supports_terminal_sequences(stream)
|
type_: not self.params.get('no_color') and supports_terminal_sequences(stream)
|
||||||
for type_, stream in self._out_files.items_ if type_ != 'console'
|
for type_, stream in self._out_files.items_ if type_ != 'console'
|
||||||
|
@ -5659,7 +5659,6 @@ def windows_enable_vt_mode():
|
|||||||
|
|
||||||
dll = ctypes.WinDLL('kernel32', use_last_error=False)
|
dll = ctypes.WinDLL('kernel32', use_last_error=False)
|
||||||
handle = os.open('CONOUT$', os.O_RDWR)
|
handle = os.open('CONOUT$', os.O_RDWR)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
h_out = ctypes.wintypes.HANDLE(msvcrt.get_osfhandle(handle))
|
h_out = ctypes.wintypes.HANDLE(msvcrt.get_osfhandle(handle))
|
||||||
dw_original_mode = ctypes.wintypes.DWORD()
|
dw_original_mode = ctypes.wintypes.DWORD()
|
||||||
@ -5671,15 +5670,13 @@ def windows_enable_vt_mode():
|
|||||||
dw_original_mode.value | ENABLE_VIRTUAL_TERMINAL_PROCESSING))
|
dw_original_mode.value | ENABLE_VIRTUAL_TERMINAL_PROCESSING))
|
||||||
if not success:
|
if not success:
|
||||||
raise Exception('SetConsoleMode failed')
|
raise Exception('SetConsoleMode failed')
|
||||||
except Exception as e:
|
|
||||||
write_string(f'WARNING: Cannot enable VT mode - {e}')
|
|
||||||
else:
|
|
||||||
global WINDOWS_VT_MODE
|
|
||||||
WINDOWS_VT_MODE = True
|
|
||||||
supports_terminal_sequences.cache_clear()
|
|
||||||
finally:
|
finally:
|
||||||
os.close(handle)
|
os.close(handle)
|
||||||
|
|
||||||
|
global WINDOWS_VT_MODE
|
||||||
|
WINDOWS_VT_MODE = True
|
||||||
|
supports_terminal_sequences.cache_clear()
|
||||||
|
|
||||||
|
|
||||||
_terminal_sequences_re = re.compile('\033\\[[^m]+m')
|
_terminal_sequences_re = re.compile('\033\\[[^m]+m')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user