Skip to content

Commit

Permalink
Take into account resume_len when calculating speed and ETA
Browse files Browse the repository at this point in the history
  • Loading branch information
rg3 committed Dec 15, 2010
1 parent b905e5f commit 975a91d
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions youtube-dl
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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()
Expand Down

0 comments on commit 975a91d

Please sign in to comment.