Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff -crB youtube-dl-github/youtube-dl youtube-dl-modified/youtube-dl
- *** youtube-dl-github/youtube-dl 2011-09-12 20:09:03.515998416 -0400
- --- youtube-dl-modified/youtube-dl 2011-09-12 20:07:00.957530608 -0400
- ***************
- *** 435,440 ****
- --- 435,441 ----
- retries: Number of times to retry for HTTP error 5xx
- continuedl: Try to continue downloads if possible.
- noprogress: Do not print the progress bar.
- + percentstop: Stop at a specific percent into the download.
- playliststart: Playlist item to start at.
- playlistend: Playlist item to end at.
- logtostderr: Log messages to stderr instead of stdout.
- ***************
- *** 482,495 ****
- return '%6s' % ('%3.1f%%' % (float(byte_counter) / float(data_len) * 100.0))
- @staticmethod
- ! def calc_eta(start, now, total, current):
- if total is None:
- return '--:--'
- dif = now - start
- if current == 0 or dif < 0.001: # One millisecond
- return '--:--'
- rate = float(current) / dif
- ! eta = long((float(total) - float(current)) / rate)
- (eta_mins, eta_secs) = divmod(eta, 60)
- if eta_mins > 99:
- return '--:--'
- --- 483,499 ----
- return '%6s' % ('%3.1f%%' % (float(byte_counter) / float(data_len) * 100.0))
- @staticmethod
- ! def calc_eta(self, start, now, total, current):
- if total is None:
- return '--:--'
- dif = now - start
- if current == 0 or dif < 0.001: # One millisecond
- return '--:--'
- rate = float(current) / dif
- ! part = float(self.params.get('percentstop',100)) / 100 * float(total)
- ! finaltotal = float(total) - float(part)
- !
- ! eta = long((float(finaltotal) - float(current)) / rate)
- (eta_mins, eta_secs) = divmod(eta, 60)
- if eta_mins > 99:
- return '--:--'
- ***************
- *** 926,931 ****
- --- 930,936 ----
- byte_counter = 0 + resume_len
- block_size = 1024
- start = time.time()
- + percentstop = 0;
- while True:
- # Download and write
- before = time.time()
- ***************
- *** 954,962 ****
- # Progress message
- percent_str = self.calc_percent(byte_counter, data_len)
- ! 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 - resume_len)
- --- 959,972 ----
- # Progress message
- percent_str = self.calc_percent(byte_counter, data_len)
- ! eta_str = self.calc_eta(self, 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)
- +
- + if int(round(float(string.replace(percent_str,'%','')))) > int(self.params.get('percentstop',100)):
- + percentstop = 1
- + self.to_screen(u'\nDone. Downloaded at least %s percent.' % str(self.params.get('percentstop',100)))
- + break
- # Apply rate limit
- self.slow_down(start, byte_counter - resume_len)
- ***************
- *** 966,972 ****
- return False
- stream.close()
- self.report_finish()
- ! if data_len is not None and byte_counter != data_len:
- raise ContentTooShortError(byte_counter, long(data_len))
- self.try_rename(tmpfilename, filename)
- --- 976,982 ----
- return False
- stream.close()
- self.report_finish()
- ! if data_len is not None and byte_counter != data_len and percentstop == 0:
- raise ContentTooShortError(byte_counter, long(data_len))
- self.try_rename(tmpfilename, filename)
- ***************
- *** 3379,3384 ****
- --- 3389,3396 ----
- dest='ratelimit', metavar='LIMIT', help='download rate limit (e.g. 50k or 44.6m)')
- general.add_option('-R', '--retries',
- dest='retries', metavar='RETRIES', help='number of retries (default is 10)', default=10)
- + general.add_option('--percentstop',
- + dest='percentstop', metavar='NUMBER', help='stop at a set percent (default is 100)', default=100)
- general.add_option('--playlist-start',
- dest='playliststart', metavar='NUMBER', help='playlist video to start at (default is 1)', default=1)
- general.add_option('--playlist-end',
- ***************
- *** 3602,3607 ****
- --- 3614,3620 ----
- 'retries': opts.retries,
- 'continuedl': opts.continue_dl,
- 'noprogress': opts.noprogress,
- + 'percentstop': opts.percentstop,
- 'playliststart': opts.playliststart,
- 'playlistend': opts.playlistend,
- 'logtostderr': opts.outtmpl == '-',
Add Comment
Please, Sign In to add comment