mirror of
https://github.com/l1ving/youtube-dl
synced 2026-06-05 12:05:16 +08:00
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
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user