From 5a1e040b8e62ae5bf20042768b002378c801747b Mon Sep 17 00:00:00 2001 From: John Hawkinson Date: Sun, 9 Oct 2016 10:36:40 -0400 Subject: [PATCH] report_progress() shouldn't fail w/o total_bytes In the absence of the total_bytes key, just say "Completed" (looks better than a bare "100%"). Compose the msg_template additively. In practice, for pipes (where we lack total bytes) we also lack elapsed time, so we end up with: [download] Completed though if elapsed time were somehow set we'd have: [download] Completed in 00:10 --- youtube_dl/downloader/common.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/youtube_dl/downloader/common.py b/youtube_dl/downloader/common.py index 8482cbd84..c23263511 100644 --- a/youtube_dl/downloader/common.py +++ b/youtube_dl/downloader/common.py @@ -242,12 +242,14 @@ class FileDownloader(object): if self.params.get('noprogress', False): self.to_screen('[download] Download completed') else: - s['_total_bytes_str'] = format_bytes(s['total_bytes']) + if s.get('total_bytes') is not None: + s['_total_bytes_str'] = format_bytes(s['total_bytes']) + msg_template = '100%% of %(_total_bytes_str)s' + else: + msg_template = 'Completed' if s.get('elapsed') is not None: s['_elapsed_str'] = self.format_seconds(s['elapsed']) - msg_template = '100%% of %(_total_bytes_str)s in %(_elapsed_str)s' - else: - msg_template = '100%% of %(_total_bytes_str)s' + msg_template += ' in %(_elapsed_str)s' self._report_progress_status( msg_template % s, is_last_line=True)