diff options
author | Philipp Hagemeister <[email protected]> | 2013-12-08 06:53:46 +0100 |
---|---|---|
committer | Philipp Hagemeister <[email protected]> | 2013-12-08 06:53:46 +0100 |
commit | 4c5216064657b267de378a84dd8ea4989934f25c (patch) | |
tree | 6de127771257c7d4b9eeeba5c94077f4f3be4616 /youtube_dl | |
parent | a213880aaffb0c236cb0b2141f167bca307f2628 (diff) | |
download | youtube-dl-4c5216064657b267de378a84dd8ea4989934f25c.tar.gz youtube-dl-4c5216064657b267de378a84dd8ea4989934f25c.zip |
[FileDownloader] Fix progress report on Windows (Fixes #1918)
Diffstat (limited to 'youtube_dl')
-rw-r--r-- | youtube_dl/FileDownloader.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/youtube_dl/FileDownloader.py b/youtube_dl/FileDownloader.py index ac6a6d8a0..8f9577512 100644 --- a/youtube_dl/FileDownloader.py +++ b/youtube_dl/FileDownloader.py @@ -205,12 +205,20 @@ class FileDownloader(object): self.to_screen(u'[download] Destination: ' + filename) def _report_progress_status(self, msg, is_last_line=False): - clear_line = (u'\x1b[K' if sys.stderr.isatty() and os.name != 'nt' else u'') + fullmsg = u'[download] ' + msg if self.params.get('progress_with_newline', False): - self.to_screen(u'[download] ' + msg) + self.to_screen(fullmsg) else: - self.to_screen(u'\r%s[download] %s' % (clear_line, msg), - skip_eol=not is_last_line) + if os.name == 'nt': + prev_len = getattr(self, '_report_progress_prev_line_length', + 0) + if prev_len > len(fullmsg): + fullmsg += u' ' * (prev_len - len(fullmsg)) + self._report_progress_prev_line_length = len(fullmsg) + clear_line = u'\r' + else: + clear_line = (u'\r\x1b[K' if sys.stderr.isatty() else u'\r') + self.to_screen(clear_line + fullmsg, skip_eol=not is_last_line) self.to_console_title(u'youtube-dl ' + msg) def report_progress(self, percent, data_len_str, speed, eta): |