From 3df4f81dfe57e973a4ae79552e13828f616d74ea Mon Sep 17 00:00:00 2001 From: pukkandan Date: Sun, 31 Jul 2022 04:20:02 +0530 Subject: [PATCH] [downloader] Add average speed to final progress line Fixes: https://github.com/ytdl-org/youtube-dl/issues/31122 --- yt_dlp/downloader/common.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/yt_dlp/downloader/common.py b/yt_dlp/downloader/common.py index f502253bf..e24d951b1 100644 --- a/yt_dlp/downloader/common.py +++ b/yt_dlp/downloader/common.py @@ -335,7 +335,10 @@ class FileDownloader: if s['status'] == 'finished': if self.params.get('noprogress'): self.to_screen('[download] Download completed') + speed = try_call(lambda: s['total_bytes'] / s['elapsed']) s.update({ + 'speed': speed, + '_speed_str': self.format_speed(speed).strip(), '_total_bytes_str': format_bytes(s.get('total_bytes')), '_elapsed_str': self.format_seconds(s.get('elapsed')), '_percent_str': self.format_percent(100), @@ -344,6 +347,7 @@ class FileDownloader: '100%%', with_fields(('total_bytes', 'of %(_total_bytes_str)s')), with_fields(('elapsed', 'in %(_elapsed_str)s')), + with_fields(('speed', 'at %(_speed_str)s')), delim=' ')) if s['status'] != 'downloading':