diff options
author | pukkandan <pukkandan.ytdlp@gmail.com> | 2021-11-29 02:55:37 +0530 |
---|---|---|
committer | pukkandan <pukkandan.ytdlp@gmail.com> | 2021-11-29 22:51:18 +0530 |
commit | 7578d77d8c0c6b000728c38fa93a1cb0f0b11ec1 (patch) | |
tree | bbd88bf8ddc2fc0b84e27aa1bf67068c19b8050d /yt_dlp/YoutubeDL.py | |
parent | b29165267f931c1135dabb7986b253f9c5673c52 (diff) | |
download | hypervideo-pre-7578d77d8c0c6b000728c38fa93a1cb0f0b11ec1.tar.lz hypervideo-pre-7578d77d8c0c6b000728c38fa93a1cb0f0b11ec1.tar.xz hypervideo-pre-7578d77d8c0c6b000728c38fa93a1cb0f0b11ec1.zip |
[downloader] Add colors to download progress
Diffstat (limited to 'yt_dlp/YoutubeDL.py')
-rw-r--r-- | yt_dlp/YoutubeDL.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.py index 73834b70f..496b0e22d 100644 --- a/yt_dlp/YoutubeDL.py +++ b/yt_dlp/YoutubeDL.py @@ -849,24 +849,24 @@ class YoutubeDL(object): WARNING = 'yellow' SUPPRESS = 'light black' - def __format_text(self, out, text, f, fallback=None, *, test_encoding=False): - assert out in ('screen', 'err') + def _format_text(self, handle, allow_colors, text, f, fallback=None, *, test_encoding=False): if test_encoding: original_text = text - handle = self._screen_file if out == 'screen' else self._err_file encoding = self.params.get('encoding') or getattr(handle, 'encoding', 'ascii') text = text.encode(encoding, 'ignore').decode(encoding) if fallback is not None and text != original_text: text = fallback if isinstance(f, self.Styles): f = f._value_ - return format_text(text, f) if self._allow_colors[out] else text if fallback is None else fallback + return format_text(text, f) if allow_colors else text if fallback is None else fallback def _format_screen(self, *args, **kwargs): - return self.__format_text('screen', *args, **kwargs) + return self._format_text( + self._screen_file, self._allow_colors['screen'], *args, **kwargs) def _format_err(self, *args, **kwargs): - return self.__format_text('err', *args, **kwargs) + return self._format_text( + self._err_file, self._allow_colors['err'], *args, **kwargs) def report_warning(self, message, only_once=False): ''' |