mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-12 10:11:07 +01:00
Show the time taken to download in the same format as the ETA
This commit is contained in:
parent
6d38616e67
commit
af8bd6a82d
@ -63,6 +63,17 @@ def format_bytes(bytes):
|
|||||||
converted = float(bytes) / float(1024 ** exponent)
|
converted = float(bytes) / float(1024 ** exponent)
|
||||||
return '%.2f%s' % (converted, suffix)
|
return '%.2f%s' % (converted, suffix)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def format_seconds(seconds):
|
||||||
|
(mins, secs) = divmod(seconds, 60)
|
||||||
|
(hours, eta_mins) = divmod(mins, 60)
|
||||||
|
if hours > 99:
|
||||||
|
return '--:--:--'
|
||||||
|
if hours == 0:
|
||||||
|
return '%02d:%02d' % (mins, secs)
|
||||||
|
else:
|
||||||
|
return '%02d:%02d:%02d' % (hours, mins, secs)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def calc_percent(byte_counter, data_len):
|
def calc_percent(byte_counter, data_len):
|
||||||
if data_len is None:
|
if data_len is None:
|
||||||
@ -78,14 +89,7 @@ def calc_eta(start, now, total, current):
|
|||||||
return '--:--'
|
return '--:--'
|
||||||
rate = float(current) / dif
|
rate = float(current) / dif
|
||||||
eta = int((float(total) - float(current)) / rate)
|
eta = int((float(total) - float(current)) / rate)
|
||||||
(eta_mins, eta_secs) = divmod(eta, 60)
|
return FileDownloader.format_seconds(eta)
|
||||||
(eta_hours, eta_mins) = divmod(eta_mins, 60)
|
|
||||||
if eta_hours > 99:
|
|
||||||
return '--:--:--'
|
|
||||||
if eta_hours == 0:
|
|
||||||
return '%02d:%02d' % (eta_mins, eta_secs)
|
|
||||||
else:
|
|
||||||
return '%02d:%02d:%02d' % (eta_hours, eta_mins, eta_secs)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def calc_speed(start, now, bytes):
|
def calc_speed(start, now, bytes):
|
||||||
@ -240,8 +244,8 @@ def report_finish(self, data_len_str, tot_time):
|
|||||||
self.to_screen(u'[download] Download completed')
|
self.to_screen(u'[download] Download completed')
|
||||||
else:
|
else:
|
||||||
clear_line = (u'\x1b[K' if sys.stderr.isatty() and os.name != 'nt' else u'')
|
clear_line = (u'\x1b[K' if sys.stderr.isatty() and os.name != 'nt' else u'')
|
||||||
self.to_screen(u'\r%s[download] 100%% of %s in %ss' %
|
self.to_screen(u'\r%s[download] 100%% of %s in %s' %
|
||||||
(clear_line, data_len_str, int(tot_time)))
|
(clear_line, data_len_str, self.format_seconds(tot_time)))
|
||||||
|
|
||||||
def _download_with_rtmpdump(self, filename, url, player_url, page_url, play_path, tc_url):
|
def _download_with_rtmpdump(self, filename, url, player_url, page_url, play_path, tc_url):
|
||||||
self.report_destination(filename)
|
self.report_destination(filename)
|
||||||
|
Loading…
Reference in New Issue
Block a user