From 975a91d0ac950f8558067810ba64adb2fb4feada Mon Sep 17 00:00:00 2001 From: Ricardo Garcia Date: Wed, 15 Dec 2010 21:42:11 +0100 Subject: [PATCH] Take into account resume_len when calculating speed and ETA --- youtube-dl | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/youtube-dl b/youtube-dl index 7d4344ae0..cf0e9fcb8 100755 --- a/youtube-dl +++ b/youtube-dl @@ -617,10 +617,9 @@ class FileDownloader(object): before = time.time() data_block = data.read(block_size) after = time.time() - data_block_len = len(data_block) - if data_block_len == 0: + if len(data_block) == 0: break - byte_counter += data_block_len + byte_counter += len(data_block) # Open file just in time if stream is None: @@ -635,16 +634,16 @@ class FileDownloader(object): except (IOError, OSError), err: self.trouble(u'\nERROR: unable to write data: %s' % str(err)) return False - block_size = self.best_block_size(after - before, data_block_len) + block_size = self.best_block_size(after - before, len(data_block)) # Progress message percent_str = self.calc_percent(byte_counter, data_len) - eta_str = self.calc_eta(start, time.time(), data_len, byte_counter) - speed_str = self.calc_speed(start, time.time(), byte_counter) + eta_str = self.calc_eta(start, time.time(), data_len - resume_len, byte_counter - resume_len) + speed_str = self.calc_speed(start, time.time(), byte_counter - resume_len) self.report_progress(percent_str, data_len_str, speed_str, eta_str) # Apply rate limit - self.slow_down(start, byte_counter) + self.slow_down(start, byte_counter - resume_len) stream.close() self.report_finish()