mirror of https://github.com/yt-dlp/yt-dlp.git
Take into account resume_len when calculating speed and ETA
This commit is contained in:
parent
b905e5f583
commit
975a91d0ac
13
youtube-dl
13
youtube-dl
|
@ -617,10 +617,9 @@ class FileDownloader(object):
|
||||||
before = time.time()
|
before = time.time()
|
||||||
data_block = data.read(block_size)
|
data_block = data.read(block_size)
|
||||||
after = time.time()
|
after = time.time()
|
||||||
data_block_len = len(data_block)
|
if len(data_block) == 0:
|
||||||
if data_block_len == 0:
|
|
||||||
break
|
break
|
||||||
byte_counter += data_block_len
|
byte_counter += len(data_block)
|
||||||
|
|
||||||
# Open file just in time
|
# Open file just in time
|
||||||
if stream is None:
|
if stream is None:
|
||||||
|
@ -635,16 +634,16 @@ class FileDownloader(object):
|
||||||
except (IOError, OSError), err:
|
except (IOError, OSError), err:
|
||||||
self.trouble(u'\nERROR: unable to write data: %s' % str(err))
|
self.trouble(u'\nERROR: unable to write data: %s' % str(err))
|
||||||
return False
|
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
|
# Progress message
|
||||||
percent_str = self.calc_percent(byte_counter, data_len)
|
percent_str = self.calc_percent(byte_counter, data_len)
|
||||||
eta_str = self.calc_eta(start, time.time(), data_len, 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)
|
speed_str = self.calc_speed(start, time.time(), byte_counter - resume_len)
|
||||||
self.report_progress(percent_str, data_len_str, speed_str, eta_str)
|
self.report_progress(percent_str, data_len_str, speed_str, eta_str)
|
||||||
|
|
||||||
# Apply rate limit
|
# Apply rate limit
|
||||||
self.slow_down(start, byte_counter)
|
self.slow_down(start, byte_counter - resume_len)
|
||||||
|
|
||||||
stream.close()
|
stream.close()
|
||||||
self.report_finish()
|
self.report_finish()
|
||||||
|
|
Loading…
Reference in New Issue