summaryrefslogtreecommitdiffstats
path: root/gallery_dl/__init__.py
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@unit193.net>2022-06-05 00:33:56 -0400
committerLibravatarUnit 193 <unit193@unit193.net>2022-06-05 00:33:56 -0400
commit25442ea49f031d4d2df3353dd7e9ad2080e332da (patch)
tree14c2ee86b8d10cf0f79b4cd3ce8d6a34ebe52eba /gallery_dl/__init__.py
parentad61a6d8122973534ab63df48f6090954bc73db6 (diff)
New upstream version 1.22.1.upstream/1.22.1
Diffstat (limited to 'gallery_dl/__init__.py')
-rw-r--r--gallery_dl/__init__.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/gallery_dl/__init__.py b/gallery_dl/__init__.py
index d66e285..9e27417 100644
--- a/gallery_dl/__init__.py
+++ b/gallery_dl/__init__.py
@@ -154,6 +154,21 @@ def main():
else:
signal.signal(signal_num, signal.SIG_IGN)
+ # enable ANSI escape sequences on Windows
+ if util.WINDOWS and config.get(("output",), "ansi"):
+ from ctypes import windll, wintypes, byref
+ kernel32 = windll.kernel32
+ mode = wintypes.DWORD()
+
+ for handle_id in (-11, -12): # stdout and stderr
+ handle = kernel32.GetStdHandle(handle_id)
+ kernel32.GetConsoleMode(handle, byref(mode))
+ if not mode.value & 0x4:
+ mode.value |= 0x4
+ kernel32.SetConsoleMode(handle, mode)
+
+ output.ANSI = True
+
# extractor modules
modules = config.get(("extractor",), "modules")
if modules is not None: